Get Procedural Skybox Sun Color in Script (Unity 5)

Hi, does anyone know of a way to get the current sun color for the procedural skybox in Unity 5 in script so it can be fed to a custom shader?

If you look at the properties of the procedural skybox shader (create a material, apply the Skybox/Procedural shader), you will find there is no property for the sun colour. This means that it’s handled internally in the shader, and you can’t get it by script through material.GetColor(), which is how you would normally read shader properties.

If you could get your hands on the source of the skybox shader, you should be able to find on what parameters the sun colour is calculated, and redo that calculation in your own shader to match colours. Alternatively, you could hack your way around this by taking colour samples at several “times of day” as it were, and interpolate between these in your shader using the sun’s rotation.

1 Like

Yeah, that’s what I was thinking I’d have to do. Was hoping there was a magic function hiding somewhere but I’ll go back to converting the procedural skybox shader to C#. Thanks!

1 Like