Is it possible to modify update skybox ambient light values at runtime?

I’m procedurally generating objects which are baked into a skybox and assigned as the RenderSettings.skybox at runtime. I have the ambient source in the scene lighting settings set to “Skybox” and the intensity at 1, but it seems like updating the skybox at runtime doesn’t cause the lighting to recalculate.

Is there any way via scripts or similar to make the skybox lighting recalculate based on the current skybox? I found RenderSettings.ambientProbe in the documentation, but haven’t found any information on how to use it.

I read in another thread that “calculations needed to crunch down a skybox to a spherical harmonics representation are quite intensive, so they need an async job” by a Unity Dev :

If there was a way to somehow do these calculations at runtime based on the current skybox, that would be awesome. Does anyone have any ideas how I might go about doing this, or if it’s even possible at the current stage? It seems like it would be quite useful for people who want to change skyboxes at runtime but also have the lighting update.

Thanks for any info!

1 Like

There are single line of code will do the skybox ambient update at runtime.

    void Update () {
        DynamicGI.UpdateEnvironment ();
    }

[Edit]
This is an expensive function, running this every frame will kill your game performance badly.
You should add your own condition when it needs to be update.

5 Likes