day-night cycle light


Anybody know of a tutorial explaining how to achive day-night cycle light?

I was wondering if you could just change the color and intensity of global light but not sure on wich colors to use.

Any help apriciated :slight_smile:

For the Sun light :

  1. full sun : 255,255,220
  2. dawn/dusk, linear fade to : 255, 60, 60
  3. then to : 0, 0, 0
    During 2, spawn a second light source, like the moon, with a blueish tint, like 20, 60, 180, placed 180° opposite to the sun.
    Don’t forget to rotate both lights around your scene.
    Some sky gradients may be nice too, from blue to orange to black.

For something more realistic, for both the sun and sky, search for Mie and Rayleigh scattering functions, like these :

Also check out the Preetham sky model, which is very good for generating nice sky gradients. The major limitation of it is that it does not support clouds in its simplest form. Further information on the Preetham model is available on the net.

thanks,these info are valuable。

thanks so much for the info!

I’ll look into it!

This is a big overkill for me.

I was going to simply use the global light so what I was looking for was a function that gives intensity (and rgb?) according to the time.

ZbuffeR was the most approximated thing but I was looking for soft changes. I will probably just change intensity according to time and do a couple of ifs for colour changes.

If anybody has a better ideas, I’m all ears :slight_smile:

Thanks again!

I was looking for soft changes

Well that is what I meant when saying “linear fade to”.
I supposed you knew how to do a simple LERP from color to color.
Do the lerp independently for each channel in parallel, that will be smooth.