Random numbers per pixel give static. Noise functions give randomness that is smooth: nearby inputs give nearby outputs, but the pattern never repeats in an obvious way. They drive clouds, terrain, flow fields, wobble on a camera, and most of what looks organic in a TouchDesigner or GLSL patch. The ideas are few: a lattice of random values, a smooth interpolation curve, and layering at several scales.

Smooth randomness: like hills and clouds, never a jumble of pixels. Image: Lord Belbury, CC0, via Wikimedia Commons.

Mental Model

  • Noise is a deterministic hash on an integer lattice plus smooth interpolation between lattice points. Same input always gives the same output.
  • Value noise interpolates random values. Gradient noise interpolates random slopes, which looks less blocky.
  • The interpolation curve decides how smooth the result is. The quintic fade has zero first and second derivative at the lattice points.
  • fBm stacks noise at doubling frequencies and halving amplitudes. Domain warping feeds noise into noise.

1. Value Noise vs Gradient Noise

Left: random heights blended together look blocky. Right: random slopes blended together look like smooth hills. Rendered from the equations on this page.

Value noise assigns a random value to each integer lattice point and blends the four (in 2D) surrounding values with a smooth weight. It is cheap, but the lattice is easy to see because the extrema always sit on lattice points, giving a boxy look.

Gradient noise, the family Perlin noise belongs to, assigns a random gradient vector to each lattice point. For a sample point , take the offset vector from each corner to , dot it with that corner’s gradient, and blend the four dot products. The result is exactly zero at every lattice point and has its extrema between them, so the grid is much less visible.

In 2D the blend is bilinear with weights from the fade curve. With fractional position :

where is the gradient dot product at corner and is the fade.

2. The Fade Curve

Interpolating linearly leaves creases at lattice lines. The original Perlin noise used , which has zero slope at and , but its second derivative is not zero there, so the second derivative of the noise jumps across cell boundaries. In bump mapping or normals this shows up as grid artifacts. The improved version (Perlin, 2002) uses

whose first and second derivatives both vanish at 0 and 1. A quick check: , , , , , and the numerical slope at is about . In Horner form: t*t*t*(t*(t*6.0 - 15.0) + 10.0).

3. Simplex Noise

Classic noise in dimensions blends corners of a hypercube, so cost doubles with each dimension. Simplex noise uses the simplest shape that tiles space instead: triangles in 2D, tetrahedra in 3D, with corners. Compared with classic gradient noise:

  • Cost grows roughly with rather than , which matters in 3D and 4D (time as the fourth axis).
  • Fewer directional artifacts, since a simplex grid has no axis-aligned bias as strong as a square grid’s.
  • A contribution is a radial falloff per corner, so the gradient is continuous without explicit interpolation.

The input is skewed onto the simplex grid with factors and in 2D, then the corner offsets are un-skewed. In a shader you usually copy a tested implementation instead of rederiving it, so I only keep the factors above for reference.

4. Fractal Brownian Motion (fBm)

Stack smaller and smaller bumps on top of big ones and flat hills turn into mountains with rocky detail. Rendered from the equations on this page.

One noise octave has a single characteristic feature size. Real terrain and clouds have detail at many sizes. fBm sums octaves:

Lacunarity is the frequency multiplier per octave (usually 2) and gain is the amplitude multiplier (usually 0.5). With these defaults the amplitudes are 1, 0.5, 0.25, … and 8 octaves sum to 1.992, so you divide by that sum (or start at amplitude 0.5) to keep the output in a fixed range. The relation defines the roughness ; gain 0.5 at lacunarity 2 gives , and a larger gain (0.6 to 0.7) makes the result rougher. Beyond about 6 to 8 octaves the extra detail falls below a pixel and costs time for nothing.

float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
 
float noise(vec2 p) {                       // value noise with quintic fade
    vec2 i = floor(p), f = fract(p);
    vec2 u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
    return mix(mix(hash(i),               hash(i + vec2(1, 0)), u.x),
               mix(hash(i + vec2(0, 1)),  hash(i + vec2(1, 1)), u.x), u.y);
}
 
float fbm(vec2 p) {                         // result in [0, 1)
    float sum = 0.0, amp = 0.5;
    for (int i = 0; i < 6; i++) { sum += amp * noise(p); p *= 2.0; amp *= 0.5; }
    return sum;
}

The sine hash is the usual quick choice, but its precision differs between GPUs, so patterns can change across devices. For stable results use an integer hash.

5. Domain Warping

Push the noise around with more noise and it starts to look like marble or smoke. Rendered from the equations on this page.

Instead of sampling at , sample at a point displaced by another noise field:

Here controls the warp strength and is an offset so the two fields differ. Nesting once more gives the swirled, marble-like images that Inigo Quilez popularized. For the displacement of a 2D point use two different offsets, one for each component. Animate by adding time to the offsets, or by using a 3D noise with time as the third coordinate.

Intuition

The warp is a smooth, random distortion of the plane. Fine features of the outer fBm get dragged along it, producing folds and filaments without ever solving a fluid equation.