River Network Formation — D8 Flow & Stream-Power Erosion

A live landscape-evolution model: D8 flow routing + flow accumulation + stream-power erosion carve a fractal, dendritic drainage network into a deforming terrain mesh.

Simulation controls

Stream power law: E = K·Am·Sn (m≈0.5, n≈1). Cells that drain a larger upstream area A erode faster, self-reinforcing into channels.

Live readouts

0
Iterations
0
Stream segments
0
Max drainage area (cells)
0.000
Mean channel slope
Ridge / high ground Flow-accumulation overlay Higher stream order
Drag to orbit · scroll / pinch to zoom · blue overlay = flow accumulation (log-scaled) · tubes = classified stream order

About this simulation

Rivers do not need to be drawn by hand to look right — they can be grown. This model starts from a rough, randomly perturbed terrain and lets water find its own way downhill, iteration after iteration, until a fractal tree of tributaries and a mainstem channel emerges purely from the physics of erosion.

🔬 What it shows

Each grid cell drains to whichever of its 8 neighbours has the steepest downhill slope (the D8 algorithm). Summing those flow paths from ridge to outlet gives every cell a drainage area — how much upstream terrain feeds through it. Erosion follows the stream power law, so cells with large drainage area cut down fastest, deepening into channels that pull even more flow toward them — a runaway feedback that produces a dendritic network almost every time.

🎮 How to use

Raise the erosion/uplift ratio to carve valleys faster than the uniform uplift can rebuild them; lower it to let the landscape stay smoother and more dome-like. Roughness sets how jagged the starting terrain is before the next regenerate. Speed controls how many D8 + erosion steps run per rendered frame. Watch the blue flow-accumulation overlay concentrate into thin lines, and the coloured tubes classify those lines by stream order as tributaries merge into a trunk stream.

💡 Did you know?

Robert Horton's 1945 laws of stream networks found that in real drainage basins, the number of streams and their lengths change by a roughly constant ratio from one order to the next — a self-similar, fractal structure that shows up whether you're looking at the Mississippi basin or a rivulet down a sandy beach.

Frequently asked questions

What is the D8 flow-direction algorithm?

D8 is the standard method hydrologists use to route water across a gridded elevation model: at each cell, water is sent entirely to whichever of the 8 surrounding neighbours (4 orthogonal, 4 diagonal) has the steepest downhill gradient. Repeating this for every cell defines a single flow path from any point on the landscape down to an outlet, which is exactly what this simulation computes on the live, deforming heightfield every step.

What is flow accumulation and why does it matter?

Flow accumulation counts how many upstream cells ultimately drain through a given cell — its contributing drainage area. It is computed by processing cells from highest to lowest elevation and passing each cell's accumulated area down to its D8 receiver, so a cell's total is only finalised once everything upstream of it has already been counted. High accumulation marks valley bottoms; because erosion depends on it, accumulation is the variable that turns a random landscape into an organised drainage network.

What is the stream power law?

The stream power law states erosion rate E = K·A^m·S^n, where A is upstream drainage area, S is local slope, K is an erodibility constant, and m and n are exponents (commonly around m≈0.5, n≈1). It captures the physical intuition that a river carves down faster where more water is funnelled through a steeper channel. This simulation applies it cell-by-cell every iteration, subtracted against a small uniform tectonic uplift that keeps the terrain from simply flattening out.

Why does a dendritic, tree-like pattern appear from almost any starting terrain?

Any tiny irregularity that concentrates a little extra flow erodes a little faster, deepening that spot relative to its surroundings; the deeper spot then captures even more of the surrounding flow, in a positive feedback loop. Because this happens simultaneously at many scales across the terrain, small rills merge into larger channels which merge into a trunk stream — producing the same branching, fractal topology seen in almost every real drainage basin regardless of the initial terrain shape.

What are Horton's laws and stream order?

Strahler stream order classifies channels hierarchically: a headwater tributary with no upstream channels is order 1; when two channels of the same order meet, the order increases by one downstream. Robert Horton observed in 1945 that the number of streams, their average length, and their drainage area change by roughly constant ratios (the bifurcation ratio, length ratio and area ratio) from one order to the next — a form of self-similarity. This simulation approximates that hierarchy by bucketing each channel cell's drainage area logarithmically and rendering higher orders as thicker, brighter tubes.

Why do erosion and uplift need to be balanced?

Without uplift, erosion would eventually wear any landscape flat, and channels would stop deepening once slopes reached zero. The small uniform uplift in this model constantly regenerates relief, so erosion always has new elevation difference to work against — closer to how real mountain landscapes reach a dynamic steady state where erosion and tectonic uplift roughly balance over geological time, sustaining the same channel network shape even as the whole surface slowly cycles material through it.

Why does the network sometimes stall or pool instead of reaching every corner of the terrain?

This is a simplified D8 model without the "pit-filling" step that professional hydrology software (like the priority-flood algorithm) uses to guarantee every cell has a downhill path to the edge. If erosion digs a cell below all of its neighbours, it becomes a local sink where accumulation pools rather than continuing downstream — visible as an isolated dark-blue spot. Raising the erosion/uplift ratio or regenerating a smoother starting terrain reduces how often this happens.

What controls how many separate channels form?

The channel threshold — the minimum drainage area a cell needs before it is classified and rendered as a stream segment — is fixed by the grid resolution in this simulation. Below that threshold, sheet flow and micro-rills are still eroding the surface (visible in the blue accumulation overlay) but are not yet coherent enough to count as a mapped channel. In real terrain the equivalent threshold is set by soil cohesion, vegetation cover and rainfall intensity, which is why drainage density varies so much between deserts, badlands and forested hillslopes.