Interactive demo
Diamond-Square Algorithm
The diamond-square algorithm builds a fractal landscape without any noise function: it starts with four corners and keeps filling in midpoints, each the average of its neighbors plus a random offset that shrinks with every level.
Press Play to build the map again from its four corners, or drag the Step slider. Coral points come from a diamond step, amber points from a square step; the lines lead to the points they average.
Controls
Square step of level 7 · grid spacing 1
Display
Legend
- Points set in earlier steps
- Diamond step: center of a square
- Square step: center of a diamond (edge midpoint)
1. Diamond step
The center of every square gets the average of its four corners plus a random offset. Together with the corners, the new centers form a pattern of diamonds, squares turned by 45°.
2. Square step
The center of every diamond, the midpoint of an edge, gets the average of the diamond's four corners, again plus an offset. At the border only three exist. Afterwards the points form squares again, with twice as many per side.
3. Roughness
After every level, the offsets are multiplied by the roughness. With 0.5 the detail shrinks as fast as the grid, like fractal noise with a gain of 0.5; higher values give jagged mountains. Straight creases along the first grid lines are a known artifact of the algorithm.
Credits
- The algorithm was published in Computer rendering of stochastic models by Alain Fournier, Don Fussell and Loren Carpenter (Communications of the ACM, 1982).