Tech News
← Back to articles

Analytic Fog Rendering with Volumetric Primitives (2025)

read original related products more articles

In this post I’m going to cover a neat technique for rendering regions of fog with varying density. I’ll start by covering some of the basic principles behind fog rendering and a few common solutions before describing the technique itself. There will be a bit of maths involved – you’ve been warned!

A Brief Review of Fog Rendering

For those unfamiliar, rendering fog boils down to simulating the behaviour of light as it passes through a medium. The simplest behaviour we can model and the one we’re going to focus on is absorption, or the loss of light energy. In basic terms, the more ‘stuff’ that light has to pass through, the more energy it loses.

A light ray loses energy as it travels through a medium (shaded region).

The ratio of outgoing light to incoming light after a given ray passes through a medium is called the transmittance, its value defined as:

Where is the amount of light entering the medium and is the amount coming out. The relationship between the density of the medium and transmittance is described by the Beer-Lambert Law. The equation is:

Where is the total density encountered by the light path going through the medium. Once we have the transmittance, we can just multiply it by to find out how much outgoing light reaches us through the ray. If the medium is just an area of constant density , then simply evaluates to the length of the portion of the light ray passing through the medium times the density:

This is more or less the approach the approach used to render simple distance fog in games. Sometimes the Beer-Lambert Law is foregone completely and just the total density along the ray is used to fade objects in the distance. Either way this approach not only assumes a medium of constant density, but that the medium itself covers the entire viewable area.

An example of basic exponential distance fog.

By constraining our medium within a bounded region we can give ourselves a bit more flexibility on the appearance of fog within a scene. The simplest approach is to use primitives such as planes, spheres or boxes as bounding volumes. By determining the intersection of our view ray with these primitives we can find the length of the ray through the volume and calculate the total density using the same formula, once again assuming a constant density within the entire primitive.

... continue reading