RealityKit 仅显示暗图像

Hen*_*ich 6 augmented-reality ios swift arkit realitykit

我正在使用 ARKit 3 和 RealityKit 开发 iOS 应用程序。我想在包含图像的房间内创建虚拟 2d 平面。因此我用了

以编程方式将材质添加到 ModelEntity

但不是接近白色的图像会显示得很暗,接近黑色。我也尝试了一下UnlitMaterial。它确实创造了更好的结果,但图像仍然很暗。JPEG 和 PNG 文件仍然存在此问题。

在我使用 SceneKit 的早期版本中,我通过解决了类似的问题

sceneView.automaticallyUpdatesLighting = true
sceneView.autoenablesDefaultLighting = true
Run Code Online (Sandbox Code Playgroud)

我想这个图像确实通过这段代码启发了自己。

如何解决 RealityKit 中的问题?

可能相关: https: //forums.developer.apple.com/thread/119265

ARG*_*Geo 2

当场景照明不\xe2\x80\x99t影响材质时

\n

开箱即用的 ARView 在光估计阶段嵌入了自动照明功能。但有时,由于环境光线较差,它无法正常工作。因此,材质忽略场景照明的唯一方法是使用 UnlitMaterial 或VideoMaterial

\n

另外,请确保您的未照明材料有white颜色,并且您的jpgpng图像没有特殊的颜色配置文件。这是我的代码:

\n
import UIKit\nimport RealityKit\n\nclass ViewController : UIViewController {\n    \n    @IBOutlet var arView: ARView!\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        arView.renderOptions = [.disableGroundingShadows]\n\n        var material = UnlitMaterial(color: .white)\n        material.color.texture = .init(try! .load(named: "img", in: nil))\n\n        let mesh = MeshResource.generateSphere(radius: 0.25)\n        let model = ModelEntity(mesh: mesh, materials: [material])\n        \n        let anchor = AnchorEntity()\n        anchor.addChild(model)\n        arView.scene.anchors.append(anchor)\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n