Reputation: 93
I am currently learning to do a few things ARKit in Unity and Swift.
Does anybody how can I adapt the light of my object to the environment light?
Thanks you!
Upvotes: 4
Views: 268
Reputation: 58113
To enable ARKit's
Light Estimation
use this code:
Enable Light Estimation in viewDidLoad()
method:
configuration.lightEstimationEnabled = true
Exploit lightEstimate.ambientIntensity
to update lighting:
func renderer(_ renderer: SCNSceneRenderer,
updateAtTime time: TimeInterval) {
guard let lightEstimate = sceneView.session.currentFrame?.lightEstimate
else {
return
}
spotLight.intensity = lightEstimate.ambientIntensity
}
Also, you can read THIS STORY.
Upvotes: 1