View Full Version : day-night cycle light

06-09-2009, 10:41 AM

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 :)

06-09-2009, 03:55 PM
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 :

06-10-2009, 08:00 AM
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.

06-10-2009, 05:38 PM
thanks,these info are valuable。

06-12-2009, 07:24 AM
thanks so much for the info!

I'll look into it!

06-12-2009, 07:35 AM
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 :)

Thanks again!

06-12-2009, 07:50 AM
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 (http://en.wikipedia.org/wiki/Lerp_(computing)) from color to color.
Do the lerp independently for each channel in parallel, that will be smooth.