Clouds

How to 3D

Chapter 11: Noise

Clouds

Noise is also used to produce atmospheric effects like clouds and fog. Producing these effects realistically in 3D is expensive, so many 2D shortcuts have been invented. For example, we can just map a noise texture onto a quadrilateral, as we do in this renderer:

The appearance of wisps over a blue sky is achieved by linearly interpolating between blue and white using the sampled noise intensity as a weight. The mix function performs the interpolation.

To produce a foggy haze in a cave or forest, we render a stack of noisy quadrilaterals. In the fragment shader, each fragment is colored white, but its opacity is proportional to its noise value. If blending is enabled and if the frames are drawn back to front, the foggy quadrilaterals will obscure the objects behind.

This renderer draws a bumpy and foggy tunnel by displacing a cylinder with noise and then filling it with 16 semi-transparent noisy billboards:

Planar fog was popular in games from the early 2000s. For the fog to look convincing, it should appear as a volume. A single quadrilateral is only a flat surface. Many quadrilaterals stacked together look more like a volume, but only when viewed head on. A viewer at their side won't see any fog at all. This planar technique works best in situations with limited camera angles, like exploring a narrow cave or flying high above a terrain covered in ground fog. The renderer above fixes the camera in place, so no bad angle is possible. Probably we should investigate or invent more sophisticated techniques for situating the planes. But not now.

← Heightmaps3D Noise →