Procedural Noise: The Maths of Natural-Looking Random

Reach for the built-in random() to make a mountain range and you get static: every height independent of its neighbour, a jagged mess no terrain ever looks like. Real worlds are smoothly irregular — rolling hills, drifting clouds, weathered rock. The tool that manufactures that organic randomness is procedural noise, and it is the perfect finale for this branch: it is built from interpolation, the very idea we started with.

From white noise to fractal terrain

Step 1 — plain random is white noise. Calling \texttt{random}() at every point gives white noise: each value is independent of its neighbours, so the result jumps wildly from one sample to the next. It has no structure at any scale — useless for a heightmap, a cloud, or anything that should look continuous. We want randomness that is smooth: nearby points should have nearby values.

Step 2 — pin random values to a lattice. The key idea (this is value noise, and its cousin Perlin/gradient noise) is to be random only at the integer lattice points. Assign each whole-number coordinate i a fixed pseudo-random value v_i (Perlin assigns a random gradient instead) — and crucially derive it from a seed, so v_i is the same every single run.

Step 3 — interpolate smoothly between lattice points. For a point x between lattice points i and i+1, blend the two with a fraction f = x - i. A plain lerp would leave kinks at every lattice point, so we ease the fraction first with a smoothstep fade,

w = f^2\,(3 - 2f), \qquad n(x) = (1-w)\,v_i + w\,v_{i+1}.

Because w has zero slope at f=0 and f=1, the curve arrives and leaves each lattice point flat — no kinks. The result is a continuous, smooth wavy field that still looks random but never jumps. (Perlin noise eases the same way; it just interpolates dot-products of the random gradients, which removes the faint grid artefacts of value noise.)

Step 4 — one octave is too plain; stack several. A single noise curve has features at one scale only — gentle, but bland. Nature has big shapes and fine detail. So we add copies of the same noise at different scales, called octaves. Each successive octave doubles the frequency (squeezes the wiggles closer) and halves the amplitude (shrinks their height):

N(x) = \sum_{k=0}^{K-1} \frac{1}{2^{k}}\; n\!\left(2^{k} x\right).

Octave 0 lays down the broad mountains; octave 1 at half the amplitude adds foothills; octave 2 adds boulders; and so on, each adding finer, fainter detail. This sum is fractal noise (often "fBm", fractional Brownian motion) — the self-similar roughness that reads as real terrain. (The amplitude ratio, persistence, and frequency ratio, lacunarity, are tunable; \tfrac12 and 2 are the classic pair.)

Step 5 — it's deterministic, so it's repeatable. Every value traces back to the seeded lattice values, and the smoothstep + octave sum are fixed formulas. So the same input x (and the same seed) always gives the same N(x). That is what lets an open world stream infinite terrain that's identical on every machine and every reload — generate the chunk under the player on demand, throw it away, and regenerate it bit-for-bit later. Organic, infinite, and free to store: one function instead of a giant array.

Procedural noise manufactures smooth, natural-looking pseudo-randomness from interpolation.

The same noise function, sampled differently, builds an astonishing range of a game's natural content:

Build the wiggle: octaves and frequency

A seeded 1-D noise curve. With 1 octave it's a single smooth wave — organic but plain. Raise the octaves slider and watch finer, fainter detail pile onto the broad shape: that's the fractal sum, each layer at double the frequency and (by default) half the amplitude. The base frequency stretches or squeezes the whole pattern, and persistence tunes how quickly the higher octaves fade — drop it and the curve smooths out, raise it and the fine detail roughens up. It is seeded, so the shape is the same every time you load the page.

The end of the road — a whole world's worth of maths

And that closes the branch. Look back at the chain you've built: vectors gave you positions and directions; transforms moved, rotated and scaled them; rotations (matrices and quaternions) turned things without tearing them; projection flattened the 3-D world onto a screen; raytracing fired rays back out to light it; collision kept the solids from passing through one another; and finally curves and noise gave you smooth motion and organic, infinite worlds. Each was a small idea — a dot product, a lerp, a derivative, a smoothstep — and stacked together they are, quite literally, a whole game world's worth of mathematics. Now go build one.