Atmosphere Rendering

How to pretty-up your planet rendering Posted in:

If you start researching rendering realistic atmospheres for planets, the rabbit hole goes very deep. Having been on this particular dive a few times now, I figured it's time to actually publish some notes - partly for my own later reference, but hopefully also of use to others.

TL;DR

Right off the bat, if you just want to dive right in with a state-of-the-art atmosphere rendering technique, then go with A Scalable and Production Ready Sky and Atmosphere Rendering Technique by Sébastien Hillaire. It is the same atmosphere rendering technique used by Unreal Engine, it is fast, scalable, has less edge-cases than previous approaches, and the author has made reference source code available.

On the other hand, if you have more specialised needs, or just want to go deeper on atmosphere rendering, then stick around...

How we got here

There is a long history of realtime sky rendering, but the vast majority have been concerned with rendering the sky from (or at least near) the ground. I'm primarily interested in planetary atmosphere rendering - we want to be able to fly to space and back, with a seamless atmosphere throughout.

For planetary atmospheres, it all starts with Nishita et al's 1993 classic, Display of The Earth Taking into Account Atmospheric Scattering. This is going to lay the foundation for the all the techniques to come, so it's worth the read even if just for the basic concepts of atmospheric scattering and optical depth. It is worth noting that at the time there was no way to run these calculations in realtime.

The big jump to realtime doesn't come until 2005, when GPU Gems 2 is published. Sean O'Neil contributes Chapter 16: Accurate Atmospheric Scattering, in which he uses a 2D lookup table to accelerate Nishita's single scattering approximation. His technique is still in use here and there, as it's simple to setup and produces reasonable results when viewed from space. The major drawback to this technique is that it doesn't account for the effects of multiple scattering at all.

!

I used Sean O'Neil's technique to render the atmosphere in my Starfall demo.

Shortly after, in 2008, Bruneton and Neyret crack the multiple scattering problem with Precomputed Atmospheric Scattering. They use a large 4-dimensional lookup table packed into a 3D texture to evalaute multiple scattering, which can be precomputed on the fly using a GPGPU implementation. Although source code is made public, it's quite complicated, and adoption is somewhat hampered until 2017, when Eric Bruneton releases a new reference implementation, which also improves on the original results. This model is still widely used, and looks stunning in many applications. The main drawbacks are that the lookup tables can cause rendering artefacts in some cases, they are fairly expensive to recompute, and the technique struggles to render very thick atmospheres.

Where we stand today

And that brings us back to Sébastien Hillaire's A Scalable and Production Ready Sky and Atmosphere Rendering Technique in 2020. Hillaire eliminates the big 4D lookup table, mostly by noting that portions of the algorithm can be evaluated at significantly reduced resolutions without loss of quality in the output image. Armed with a set of much smaller lookup tables, he's able to update them all within a single frame, allowing artists live feedback as they adjust the atmosphere parameters. As a nice bonus, elimiating the big lookup table also eliminates a number of rendering artefacts, and he can render thicker atmospheres.

What's next?

The techniques I've covered up until now product great results for Earth-like atmospheres, but ideally we'd like to be able to render all sorts of planets, and we'd also like to be able to keep pushing the envelope on rendering fidelity.

With that in mind, Interactive Visualization of Atmospheric Effects for Celestial Bodies, and Physically Based Real-Time Rendering of Atmospheres using Mie Theory both tackle rendering of the Martian atmosphere, by adding improved models for aerosol size and distribution (among other changes) to Bruneton's technique. This nets more accurate rendering of Earth's atmosphere as well, and somewhere along the way they even figured out how to render rainbows...

There also may be mileage to be had in stylised rendering, for applications that don't require photorealism. The only work I'm aware of in this direction is the aptly-named Aesthetically-Oriented Atmospheric Scattering.

See also

The Virtual Terrain Project is sadly defunct, but they have a pretty good overview of atmosphere rendering up through Bruneton's work.

Bruneton himself surveyed the major atmosphere rendering approaches as of 2017 in A Qualitative and Quantitative Evaluation of 8 Clear Sky Models