Reputation: 546
We are trying to create a SCNNode with a SCNMaterial which has an image (.png extension) in ARSCNView with the ARKit framework.
The problem is that image rendering has a problem that image is shown as black and red colors only, it doesn't render image correctly.
The problem exists only in iOS 11.2 version. There is no problem in iOS 11.0, 11.1 and 11.3 beta versions.
Our code is below;
let materialMain_Front_Back = SCNMaterial()
let fromBackImage = createImage(color:mainNode_Color)
materialMain_Front_Back.diffuse.contents = UIImage(named: "nodeBackground")
let materialMain_Other = SCNMaterial()
materialMain_Other.diffuse.contents = createImage(color:mainNode_Color)
let boxGeometryMain = SCNBox(width: CGFloat(mainNode_Width), height: CGFloat(mainNode_Height), length: 0, chamferRadius: 0.0)
boxGeometryMain.firstMaterial?.diffuse.contents = UIColor.white
boxGeometryMain.materials = [materialMain_Front_Back, materialMain_Other, materialMain_Front_Back, materialMain_Other, materialMain_Other, materialMain_Other]
let nodeMain = SCNNode(geometry: boxGeometryMain)
nodeMain.position = SCNVector3(x: 0, y: 0, z: -1)
//... other codes
annotationNode.addChildNode(nodeMain)
Does anyone have an idea?
Upvotes: 0
Views: 1014
Reputation: 1358
For me, the problem only occured on device, and continues to happen on iOS 11.4.
The solution for me wasn't the image type. In my case I already had JPG textures, however the color space was greyscale.
Xcode showed this as:
Changing it to RGB fixed the problem. After changing it, Xcode shows this:
Oh, and to change from greyscale to RGB using Photoshop, it's as simple as opening the image, and selecting: Image->Mode->RGB Color, as shown here:
Upvotes: 2
Reputation: 546
I solved it just using .jpg images. Yes just using jpg image instead of png. I also reported this to Apple as a bug. They answered as that is a problem in 11.2 only with grayscale images with transparency. They fixed it in 11.3.
Upvotes: 1