【问题标题】:Image is shown as black and red colors only in ARKit图像仅在 ARKit 中显示为黑色和红色
【发布时间】:2018-07-18 22:02:50
【问题描述】:

我们正在尝试使用 ARKit 框架在 ARSCNView 中创建具有 SCNMaterial 的 SCNNode,该 SCNMaterial 具有图像(.png 扩展名)。 问题是图像渲染存在图像仅显示为黑色和红色的问题,无法正确渲染图像。 该问题仅存在于 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


    【解决方案1】:

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

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

    Xcode 显示为:

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

    哦,要使用 Photoshop 从灰度更改为 RGB,只需打开图像,然后选择:Image->Mode->RGB Color,如下所示:

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2018-09-15
        • 2020-10-08
        • 2015-02-28
        • 1970-01-01
        • 1970-01-01
        • 2020-03-18
        • 2019-12-16
        • 2017-10-05
        • 2020-03-09
        相关资源
        最近更新 更多