Something that I have had for some time now but have not write anything about is the atmosphere. On of my goals for the project was to get an atmosphere so I got a day and night circle. The technique I have been using is accurate atmospheric scattering to make the atmosphere. I have follow this tutorial from nividia (http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html), which go through the theory behind the calculations and how the technique work. Briefly is that the scattering equations nested intergral which is numerically compute the value of the integral which go down to a weighted sum calculated in a loop. Then if you take a imagined line segment and brake up the segment into n sample segments and evaluate the integrand at the center point of each sample segment. Then multiply each result by the length of the sample segment and add them all together. If you take more samples, makes the result more accurate, but then also makes the integral more expensive to calculate.

Another important detail is related to how the light scattering at the sample points. Different particles in the atmosphere scatter light in different ways. The two most common forms of scattering in the atmosphere are *Rayleigh* *scattering* and *Mie scattering*. Rayleigh scattering is caused by small molecules in the air, and it scatters light more heavily at the shorter wavelengths (blue first, then green, and then red). The sky is blue because the blue light bounces all over the place, and ultimately reaches your eyes from every direction. The sun’s light turns yellow/orange/red at sunset because as light travels far through the atmosphere, almost all of the blue and much of the green light is scattered away before it reaches you, leaving just the reddish colors.

Mie scattering is caused by larger particles in the air called aerosols (such as dust and pollution), and it tends to scatter all wavelengths of light equally. On a hazy day, Mie scattering causes the sky to look a bit gray and causes the sun to have a large white halo around it.

Some pictures of the atmosphere in my project. Showing one sunset!