我正在使用 ARKit 3 和 RealityKit 开发 iOS 应用程序。我想在包含图像的房间内创建虚拟 2d 平面。因此我使用了
Adding a material to a ModelEntity programmatically
但是不是接近白色的图像会显示得非常暗,接近黑色。我还尝试了UnlitMaterial
。它确实创造了更好的结果,但图像仍然很暗。 JPEG 和 PNG 文件仍然存在此问题。
在我使用 SceneKit 的早期版本中,我通过解决了类似的问题
sceneView.automaticallyUpdatesLighting = true
sceneView.autoenablesDefaultLighting = true
我想图像确实通过这段代码照亮了自己。
如何解决 RealityKit 中的问题?
最佳答案
let img = UIImage(named: ouputSrc, in: Bundle(path: resourcePath), compatibleWith: nil)
var myMaterial = UnlitMaterial()
myMaterial.baseColor = try! .texture(.load(named: ouputSrc, in: Bundle(path: resourcePath)))
myMaterial.tintColor = UIColor.white.withAlphaComponent(1)
关于ios - RealityKit 仅显示暗图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56986428/