Using ambientIntensity for Reality Kit AR View

Hi, I would like to check if there is any way to use .ambientIntensity command in RealityKit ar view?

Previously, I was able to obtain the ambient intensity using Scenekit view. However as I switch to Realitykit ar view, I was not able to obtain the ambient intensity. Is there any advice?
Accepted Answer
Hello,

The light estimates are provided as long as isLightEstimationEnabled is set to true on your configuration, which is the default. This is independent of a renderer, so it works regardless of whether you are using SceneKit, RealityKit, Metal, or something else for rendering.

Here is a small modification to the RealityKit template project, which shows how you can obtain the ambient intensity:

Code Block
import UIKit
import RealityKit
import ARKit
class ViewController: UIViewController, ARSessionDelegate {
    
    @IBOutlet var arView: ARView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Load the "Box" scene from the "Experience" Reality File
        let boxAnchor = try! Experience.loadBox()
        
        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)
        arView.session.delegate = self
    }
    func session(_ session: ARSession, didUpdate frame: ARFrame) {
        // Do something with the light estimates here.
        print(frame.lightEstimate?.ambientIntensity)
    }
}

Hi gchiste, firstly I would like to thank you for your fast response. I have tried to modify the code as shown by you, however, the program output stated showed that it" Failed to find reflection for buffer clusterIndexTable"
I manage to solve the issue. Thank you!
Hello Ernest,


I have tried to modify the code as shown by you, however, the program output stated showed that it" Failed to find reflection for buffer clusterIndexTable"


This message sounds like Log Noise.

Even so, you should file a bug report for the console log message using Feedback Assistant.
Using ambientIntensity for Reality Kit AR View
 
 
Q