图像仅在ARKit中显示为黑色和红色

问题描述 投票:0回答:2

我们正在尝试使用带有ARKit框架的ARSCNView中具有图像(.png扩展名)的SCNMaterial创建SCNNode。问题是图像渲染存在一个问题,即图像仅显示为黑色和红色,它不能正确渲染图像。该问题仅存在于iOS 11.2版本中。 iOS 11.0,11.1和11.3 beta版本没有问题。 我们的代码如下;

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)

有没有人有想法?

swift3 arkit scnnode ios11.2 scnmaterial
2个回答
1
投票

我只是使用.jpg图像解决了它。是的只是使用jpg图像而不是png。我还向Apple报告了这个错误。他们回答说这是11.2中的问题,只有灰度图像具有透明度。他们在11.3修正了它。


1
投票

对我来说,这个问题只出现在设备上,并且在iOS 11.4上继续发生。

我的解决方案不是图像类型。在我的情况下,我已经有JPG纹理,但颜色空间是灰度。

Xcode将此显示为:

Greyscale Setting

将其更改为RGB可以解决问题。更改后,Xcode显示:

RGB Setting

哦,使用Photoshop从灰度变为RGB,就像打开图像一样简单,选择:图像 - >模式 - > RGB颜色,如下所示:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.