Rendering realistic and dynamic skies is a challenging problem in real-time computer graphics.
I was inspired to tackle this problem after I realized that the math was very similar to volumetric lighting, which I worked on as the final project in a course I took. The math behind light scattering is too complex to solve directly in real-time, but it can be precomputed.
I wrote this program that solves the atmospheric scattering equations for every possible view and sun direction, and stores the results in look-up tables.
I also wrote a WebGL demo to show how the tables can be utilized to render a realistic sky in real-time.
The source code, as well as instructions to integrate the solution into an existing renderer are available here.
Gustav Bodare and Edvard Sandberg’s thesis on atmospheric scattering was incredibly helpful. Without it I would have been lost.