I’ve recently implemented a relatively simple atmospheric scattering simulation to my renderer. The color of the sky is due to the scattering of light by air molecules. Rayleigh scattering, which is caused by particles much smaller than the wavelengths of visible light, is responsible for the blue-ish color of the sky during the day and the red/orange color of the sky during the twilight hours. Mie scattering on the other hand is caused by aerosols and is responsible for the “haze” of light that surrounds the sun. I use both Rayleigh and Mie scattering together in order to achieve the correct the effect.
The sky itself is modeled using a 6420 kilometer sphere encapsulating a 6360 kilometer sphere used to represent the earth. The camera is translated as to be on top of the earth, so if the user places the camera at one meter above the ground at Point(0,1,0) my renderer will actually position the camera at Point(0, 6360001, 0).
Since the density of the atmosphere changes with altitude, I use ray marching along the viewing ray to take this into account. Additionally, at each sample point along the viewing ray, I use ray marching along the line of sight from that point to the sun in order to calculate the amount of light that is attenuated due to scattering before reaching that point.
Here are some of my test results thus far: