0 votes

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.

in Engine by (527 points)

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():
   'dusk':
     # 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")
  'midday':
     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)

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.