Very nicely done, slashie! Earth's atmosphere scatters different colors of light based on the position of the sun in the sky. It scatters blue much more heavily than red, namely, which means that when the sun is directly overhead, the sky will be very blue. This is because the blue light is scattered just enough to be everywhere, where as the red light is mostly unscattered. At sunset, the blue light is scattered so much that it is very dim, where as the red light finally begins to be scattered as the blue light was at noon, resulting in a redish sunset and sunrise.
Pseudo C:
struct Atmosphere
{
float RScatter,GScatter,BScatter; //How much R, G and B are scattered at noon.
float Density;
}
struct Sun
{
float RColor,GColor,BColor;
float Intensity;
float HeightInSky; //1 = directly overhead, 0 and 2 are on the horizon.
}
SkyRColor = Sun.Intensity*Sun.RColor*(Atmosphere.RScatter*(abs(1-Sun.HeightInSky)+Atmosphere.Density));
SkyGColor = Sun.Intensity*Sun.GColor*Atmosphere.GScatter;
SkyBColor = Sun.Intensity*Sun.BColor*(Atmosphere.BScatter*(1-(abs(1-Sun.HeightInSky)+Atmosphere.Density)));
I'm sure there are some improvements that can be made, but that's my general idea.