How to set a single environmental lightprobe?

I’m working on an algorithm which estimates the environmental lighting of a real world scene. The algorithm returns back the 27 values SphericalHarmonicsL2 probe.
How can I use these values, to light a virtual scene?
I have already removed all of the world lighting (skybox,…) in the Windows->Rendering->Lighting window.

Hey there,

You should be able to set RenderSettings.ambientProbe to your desired SphericalHarmonicsL2 object. You’ll probably also want to set RenderSettings.ambientMode to AmbientMode.Custom to avoid issues related to the skybox.

That should work fine in playmode, but might seem to ‘flicker’ in the editor. That’s a known issue, and if you run into it you should be able to solve it by just baking lighting once (Window > Rendering > Lighting > Generate Lighting).

Let me know if this helps :slight_smile:

Thank you so much for the reply.
In the meantime I ended up writing my own shader, where I set the vertex light (color) from the environment probe and the per-vertex-probe (which is also calculated during the light estimation).

Anyway…setting the ambientProbe is possible during runtime? Could one also set multiple light probes, similar to light probe groups. I have to add, this is for an AR app running on Android, where I want to achieve coherent rendering of the virtually added objects in my RL-scene.

There is just one ambient probe, and that can indeed be changed dynamically. For light probe groups, you can change the SH coefficients by accessing LightmapSettings.lightProbes.bakedProbes which is just an array of SphericalHarmonicsL2.

1 Like