November 10, 2026

Erosion Simulator: Watch Rain Carve a Random Mountain Into River Valleys

Aerial view of branching gullies in desert badlands

Start with a lump of noise. Let it rain. Within a few hundred thousand raindrops the lump has ridges, the ridges have gullies, the gullies join into valleys, and the valleys drain into a branching network that looks like a satellite photograph of somewhere real. The simulation in this article does nothing more sophisticated than drop water particles on a heightmap and let each one run downhill, picking up soil where it moves fast and dropping it where it slows. That is also, in outline, what hydraulic erosion does to a landscape, and the method behind the simulator comes from a 2015 bachelor’s thesis that most of the game industry has since borrowed.

Video: Sebastian Lague, “Coding Adventure: Hydraulic Erosion”

What the simulator does

A 256-cell heightmap, rain by the slider, and three ways to look at it

The terrain is a 256-by-256 grid of heights built from several octaves of Perlin noise, so it starts as rounded hills with no drainage at all. Erode starts the rain; Drops per frame sets how many particles land each frame, from 50 to 3,000. The Show menu switches between Shaded relief, the default, which lights the terrain from one side and colours it by elevation; Height, a plain elevation map; and Sediment moved, which paints where material has been removed and where it has been deposited, the simulator’s equivalent of a before-and-after survey.

Four sliders control the physics. Erosion sets how much soil a drop can pick up per step, Deposition how much it drops, Evaporation how quickly a drop shrinks, and Inertia how much a drop keeps its heading rather than turning straight downhill. Seed picks a different starting terrain; New terrain regenerates. The page is at apps.x9m8.com/erosion, with the source on GitHub.

How a raindrop erodes a hill

Capacity, speed, water, and the difference between picking up and putting down

Hydraulic erosion is the removal of soil, rock or dissolved material from one location and its transport to another, where it is deposited. Rainfall does it in stages. Splash erosion comes first: the impact of a falling raindrop creates a small crater and ejects particles up to about 0.6 m vertically and 1.5 m horizontally. Once the ground is saturated, overland flow carries the loosened particles as sheet erosion, then concentrates into rills a few centimetres deep, then gullies that cut to considerable depth. Rainfall amount and intensity are the main climatic controls; in the mid-western United States intensity dominates, while in western Europe the total amount matters more.

The simulator models the particle version of this. The algorithm follows Hans Theobald Beyer’s thesis, Implementation of a method for hydraulic erosion, submitted to the Department of Informatics at the Technische Universität München in November 2015. As Beyer puts it, “The drops are simulated in 2.5D, which means the drop is considered to be always at ground level.” Each drop lands at a random cell with a small amount of water and no sediment. At every step it reads the local gradient by bilinear interpolation of the four surrounding cells, blends that downhill direction with its previous heading according to the inertia parameter, and moves one cell.

What happens next depends on a single number, the carrying capacity. Beyer defines it as the product of the slope just descended, the drop’s speed, its water volume and a capacity constant, with a minimum slope so that erosion does not stall on flat ground. A fast drop with plenty of water on a steep slope can carry a lot. If it is carrying less than its capacity, it erodes: it removes a fraction of the shortfall from the cells within an erosion radius, weighted so that the nearest cells lose most, and never more than the height drop allows, which prevents the drop from digging a pit. If it is carrying more than its capacity, because the slope flattened or the water evaporated, it deposits a fraction of the excess onto the four cells around it. Speed updates from the height difference and gravity; water decreases by the evaporation fraction each step; and the drop ends after a fixed number of steps, when it leaves the map, or when it settles in a hollow with nowhere to go.

Every valley on the screen is the sum of those decisions. Drops that happen to follow the same channel deepen it, which steers the next drops into it, which deepens it further. The branching network is not designed; it is the accumulated preference of a few hundred thousand independent particles for the paths that earlier particles cut.

Raindrop splashing into bare soil in close-up

Where the method came from

Chiba in 1999, Beyer in 2015, and a lot of games since

Particle-based erosion is older than Beyer’s thesis. Luther Tychonievich’s course notes for CS 418 at the University of Illinois credit Chiba, Muraoka and colleagues in 1999 with the first particle technique, and describe the same loop: particles “are distributed based on rainfall models and roll down hill,” accelerate along the surface normal, lose speed to friction, exchange sediment against a capacity of the form carrying constant times speed times water volume, and evaporate until they are gone. Those notes put the particle count needed at several hundred thousand, which matches what the simulator needs before the drainage network is fully formed.

Beyer’s contribution was to write the whole procedure down with every parameter named and every edge case handled, in a form a programmer could implement in an afternoon. That is why it spread. Open-source implementations such as erodr cite the thesis directly, and the method appears, in one variant or another, in terrain tools and game engines whenever a landscape needs to look weathered rather than smooth.

The terrain the simulator starts from is also a borrowed technique: fractal noise, several octaves of Perlin noise summed at decreasing amplitude, which gives hills that are self-similar across scales but have no memory of water. Erosion supplies the memory.

Muddy river meeting clear lake water

What the simulator leaves out

Rock, vegetation, time, and the things geology adds

Real erosion rates depend on slope steepness, rainfall, wind and temperature, and on what the ground is made of. The simulator has one material, uniformly soft. It has no bedrock to resist a channel, no vegetation to bind the soil, no freeze-thaw, no wind. It also has no tectonics, so nothing pushes the terrain back up while the rain wears it down, which is why a long run ends in a flattened plain with a few residual hills rather than a mountain range in equilibrium.

Water is not the only agent, either. Wind erosion moves soil mainly by saltation, grains bouncing along the surface, which accounts for 50 to 70% of the total, with suspension taking 30 to 40% and surface creep the rest; in the Great Plains, soil loss to wind in drought years can be thousands of times greater than in wet ones. Ice and heat do their own work: along the Lena River in Siberia, thermal erosion of frozen banks drives rapid channel migration, and a 100 km stretch of the Beaufort Sea shoreline eroded at an average of 5.6 m a year between 1955 and 2002. The floods from glacial Lake Missoula cut the channeled scablands of eastern Washington in events that would overwhelm any drop-by-drop model.

The scale of what it is missing is worth stating. Human activity has raised global soil erosion rates by 10 to 40 times the natural rate, and water and wind erosion together account for about 84% of the global extent of degraded land. On the other end of the timescale, the Great Unconformity article on this site describes a kilometre-high escarpment that retreated across what is now the Grand Canyon region as Rodinia broke apart around 800 million years ago, stripping rock long before any canyon was cut. Those are the processes a 256-cell grid and a few hundred thousand drops gesture at.

Hand on layered sandstone strata in a road cut

Experiments worth running

  • Set Inertia to zero and run. Drops turn straight downhill every step, and the channels come out jagged. Raise Inertia to 0.3 and the same terrain develops smooth, sweeping valleys.
  • Push Erosion to 0.5 and Deposition to 0.01. The terrain is stripped to a plain in seconds, and the Sediment moved view shows almost nothing deposited anywhere.
  • Reverse it: Erosion 0.01, Deposition 0.5. Drops drop what they carry almost immediately, and the result is terracing rather than valleys.
  • Set Evaporation to its minimum. Drops survive their full lifetime, travel far, and carve long channels that reach the edge of the map.
  • Pick a seed, run for a minute, note the drainage pattern, then regenerate with the same seed and run again. The same terrain yields the same rivers, because the only randomness is where the drops land.

John McPhee’s Annals of the Former World is the book-length version of the thing the simulator compresses into a minute: the geology of North America read from the rock, one road cut at a time.

Annals of the Former World by John McPhee. The geology of North America read from the rock, one road cut at a time. See it on Amazon (affiliate link)

As an Amazon Associate I earn from qualifying purchases. A commission may be earned if you buy through this link, at no extra cost to you.

Sources

394 Posts

Peter Kalafatis writes and edits X9M8. He holds a bachelor's degree from LIU Post and a master's in Media Studies from The New School, with academic work in the philosophy of science, human behavior, AI, and memetics.

View All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

You Missed