Dynamic sky based on time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By andersmmg

I have a shader for the sky that works great, but I’m trying to figure out a good way to change shader parameters based on the time of day. I have a variable that is the time in seconds which advances, and there are times of day I’d want certain parameters to change at different times of day.
The parameters are things like cloud density, sky color, sun brightness etc.

What I would do is define the variables which control the look of the sky, e.g. the amount of sunlight, the density of the clouds, the cloud color, the number of clouds, the sight of the stars. Then I would feed those into the shader:

match get_time_of_day():
     # This selects the first ShaderMaterial, but you could probably do this for other shader materials.
     sky.get_shader_material( 0 ).set_shader_param("amount_of_light", 0.23)
     sky.get_shader_material( 0 ).set_shader_param("starry_sky", true)
     sky.get_shader_material( 0 ).set_shader_param("cloud_color", "auburn")
     sky.get_shader_material( 0 ).set_shader_param("amount_of_light", 1.00)
     sky.get_shader_material( 0 ).set_shader_param("cloud_color", "white")
     sky.get_shader_material( 0 ).set_shader_param("number_of_clouds", 13)

Ertain | 2020-03-14 18:11

I would like it to be a smoother transition too. I’m not sure how I would be able to tween between so many different values at different times. Maybe using target variables or something might work

andersmmg | 2020-03-14 22:59