Perlin Noise Lab (2D)

Gradient noise as greyscale, terrain map, contours, flow field and marbling, with the lattice and gradients drawn on top.

Switch to 3D

Presets

Playback

Picture

Noise settings

Layers

Model check

The science

What is modelled

A noise field is built from Ken Perlin's gradient noise and shown as a picture: greyscale, a terrain map, contour lines, particle trails in the flow field, or marbling. The noise is computed in the page for every pixel of a 256 by 256 grid.

Equations

  • Lattice: every integer point (i, j) gets a pseudo-random unit gradient gij from a seeded permutation table. For a point (x, y) in cell (i, j) with offsets (xf, yf) the four corner contributions are the dot products g · (offset to the corner).
  • Blend: n = lerp(lerp(n00, n10, u), lerp(n01, n11, u), v) with u = fade(xf), v = fade(yf). The improved fade is 6t5 - 15t4 + 10t3: its first and second derivatives vanish at 0 and 1, so the noise has continuous curvature across lattice lines. The original 3t2 - 2t3 only has a continuous slope, and its curvature jumps (visible as faint creases with a single octave).
  • The noise is exactly zero at every lattice point (all offsets are zero or the corner term is a dot product with a zero vector), and with unit gradients it is bounded by √2/2 in two dimensions.
  • Fractional Brownian motion: fBm(p) = ∑k=0m-1 ak n(lk p) with persistence a and lacunarity l. It is bounded by (∑ ak) √2/2; the page divides by that sum so the value stays in [-1, 1]. Each octave adds detail at a finer scale and a smaller amplitude.
  • Marble: sin(2π (v · bands + turbulence · ∑ ak |n(2k p)|)). The absolute value creates the creases of turbulence. The lattice wraps around the vase so the texture has no seam.

Checks run in the page

  • Zero at every lattice point for four seeds.
  • Value range from 200 000 random samples against the proven bound.
  • Continuity (finite slope that does not grow as the step shrinks) and the fade-curve derivatives.
  • The fBm amplitude bound for four octave settings.

Honest simplifications

This is a mathematical texture, not a geological model: real terrain is shaped by erosion, tectonics and water, which gradient noise does not include. Colours follow height and slope by simple rules. The marble is a standard turbulence recipe, not a model of how veins form in stone. Water is simply the area below the chosen level, and the flow field moves particles along the noise angle, it is not a fluid simulation.

What to try

  • Set octaves to 1 and switch on the lattice: the zero crossings sit exactly on the grid points.
  • Raise persistence from 0.4 to 0.7 and watch the rough fine detail overtake the large shapes in the octave graph.
  • Switch the fade to smoothstep with one octave in the contour view and look for creases along the lattice lines.
  • Change the seed: the shape changes completely but the histogram, range and statistics stay almost the same.
Noise along the slice: octave 1 vs fBm
Octave amplitudes (persistence)
Distribution of the noise values