Terrain from Hydrology (River-First Terrain Synthesis)
Build a river network first as a tree with drainage-area-based constraints, then synthesise a heightfield that is consistent with it by interpolating around the rivers and adding noise detail.
Also known as procedural terrain from river networks
In the family Procedural generation, terrain generation
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | No built-in river-first hydrology terrain synthesis tool. |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The user (or a generator) provides a coarse drainage structure: river segments, branching topology and a few elevation constraints. The algorithm expands this into a full tree where each segment's flow grows downstream, and elevations are assigned so rivers always flow downhill. Terrain between rivers is built by interpolating from the river elevations upward with a profile that depends on distance to the nearest channel and on drainage area, then adding procedural noise as detail. Since rivers are an input rather than an outcome of simulation, results are controllable and fast to compute, and the river layout is guaranteed to be hydrologically plausible. Landscape features like valley width and ridgelines follow from the tree.
When to choose it
Reach for it when
- need to place rivers exactly where i want them
- terrain should be consistent with a designed watershed
- erosion simulation takes too long for map design
- game map needs believable drainage and valleys
Choose it when you need to control where rivers and watersheds go (game maps, scenic composition) and want terrain consistent with them without running a long erosion simulation. Prefer Stream-Power Erosion (Fluvial Terrain Uplift) when you want the river network to emerge from uplift rather than be drawn, and Interactive Hydraulic Erosion on Heightfields for fine erosion detail on top.
Field marks
- Terrain between rivers is generic noise-modulated interpolation, lacking tributary gullies unless a post-erosion pass is added
- Constraints that force uphill flow need explicit repair or the tree rejects them
- Large drainage-area contrast gives unrealistically wide valleys for small rivers
- River sketches without enough branching produce flat, featureless basins
Presets
Hydrology Terrain Synthesis — Strahler river-tree & watershed map (left) vs uplifted alpine valleys (right)
{
"P_UPLIFT": 0.92,
"P_RIVER_WIDTH": 0.85,
"P_CAM_SWAY": 0.42,
"P_SPLIT": 0.46
}Show GLSL (130 lines)
const float P_UPLIFT = 0.92; // P Ridge Uplift [0.3, 1.5, 0.04]
const float P_RIVER_WIDTH = 0.85; // P River Network [0.3, 1.5, 0.04]
const float P_CAM_SWAY = 0.42; // P Camera Sway [0.0, 2.0, 0.05]
const float P_SPLIT = 0.46; // P River Tree / 3D [0.0, 1.0, 0.02]
float sdSeg(vec2 p, vec2 a, vec2 b, out float h) {
vec2 pa = p - a, ba = b - a;
h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
return length(pa - ba * h);
}
// River-first hierarchical dendritic drainage tree (Genevaux et al. 2013):
// Returns vec3(distToNearestRiver, riverElevation, strahlerOrder)
vec3 evalRiverTree(vec2 p) {
// Subtle natural meander warp
vec2 q = p + vec2(0.12 * sin(p.y * 2.2), 0.08 * cos(p.x * 2.4));
float h0, h1, h2, h3, h4;
// Order-3 main trunk river flowing from (0, -1.6) to (0, 1.8)
float dMain = sdSeg(q, vec2(0.0, -1.6), vec2(0.0, 1.8), h0);
float zMain = mix(0.22, -0.30, h0);
// Order-2 primary tributaries branching left and right
float dT1 = sdSeg(q, vec2(-1.45, -1.15), vec2(0.0, -0.25), h1);
float zT1 = mix(0.46, -0.02, h1);
float dT2 = sdSeg(q, vec2(1.45, -0.85), vec2(0.0, 0.15), h2);
float zT2 = mix(0.44, -0.08, h2);
// Order-1 headwater streams feeding tributaries
float dH1 = sdSeg(q, vec2(-1.35, 0.35), vec2(-0.62, -0.62), h3);
float zH1 = mix(0.56, 0.20, h3);
float dH2 = sdSeg(q, vec2(1.25, 0.72), vec2(0.68, -0.32), h4);
float zH2 = mix(0.54, 0.16, h4);
// Pick closest drainage segment & its Strahler order
float d = dMain; float zR = zMain; float ord = 3.0;
if (dT1 < d) { d = dT1; zR = zT1; ord = 2.0; }
if (dT2 < d) { d = dT2; zR = zT2; ord = 2.0; }
if (dH1 < d) { d = dH1; zR = zH1; ord = 1.0; }
if (dH2 < d) { d = dH2; zR = zH2; ord = 1.0; }
return vec3(d, zR, ord);
}
// Uplift watershed ridges proportionally to distance from the river network!
float evalHydroTerrain(vec2 xz, float uplift) {
vec3 rt = evalRiverTree(xz);
// Concave valley cross-section rising to sharp alpine watershed divides between rivers
float ridge = pow(clamp(rt.x * 0.95, 0.0, 1.4), 1.15) * 0.68 * uplift;
float detail = 0.08 * sin(xz.x * 5.2 + cos(xz.y * 4.7)) + 0.035 * cos(xz.x * 11.0 - xz.y * 9.5);
return rt.y + ridge + detail * smoothstep(0.05, 0.35, rt.x);
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool isMap = screenX < split;
float uplift = clamp(P_UPLIFT, 0.25, 1.6);
float rw = clamp(P_RIVER_WIDTH, 0.25, 1.6);
float sway = sin(iTime * 0.45 * max(P_CAM_SWAY, 0.0)) * 0.35;
vec3 ro = vec3(sway, 1.45, 2.55);
vec3 rd = normalize(vec3(uv.x - sway * 0.12, uv.y - 0.42, -1.32));
vec3 sky = mix(vec3(0.84, 0.88, 0.94), vec3(0.18, 0.42, 0.76), smoothstep(-0.08, 0.52, rd.y));
vec3 col = sky;
float t = 0.2;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec3 p = ro + rd * t;
float h = evalHydroTerrain(p.xz, uplift);
float d = p.y - h;
if (d < 0.008) { hit = true; break; }
t += max(d * 0.45, 0.025);
if (t > 12.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
float e = 0.016;
float hC = evalHydroTerrain(p.xz, uplift);
float hX = evalHydroTerrain(p.xz + vec2(e, 0.0), uplift);
float hZ = evalHydroTerrain(p.xz + vec2(0.0, e), uplift);
vec3 n = normalize(vec3((hC - hX) / e, 1.0, (hC - hZ) / e));
vec3 rt = evalRiverTree(p.xz);
float riverW = (0.028 + 0.024 * rt.z) * rw;
float inRiver = smoothstep(riverW * 1.4, riverW * 0.5, rt.x);
vec3 sunDir = normalize(vec3(0.62, 0.68, 0.45));
float diff = max(dot(n, sunDir), 0.0);
if (isMap) {
// Left: Topographic watershed map showing Strahler river tree orders & elevation iso-contours!
float contour = smoothstep(0.06, 0.012, abs(fract(hC * 8.0) - 0.5));
vec3 topo = mix(vec3(0.07, 0.14, 0.22), vec3(0.28, 0.52, 0.36), smoothstep(-0.25, 0.35, hC));
topo = mix(topo, vec3(0.86, 0.72, 0.42), smoothstep(0.35, 0.85, hC));
topo = mix(topo, vec3(0.95, 0.96, 1.0), contour * 0.38);
// Color river branches by Strahler order (1 = mint, 2 = cyan, 3 = bright sky-blue trunk)
vec3 ordCol = (rt.z > 2.5) ? vec3(0.16, 0.88, 1.0)
: (rt.z > 1.5 ? vec3(0.20, 0.96, 0.72) : vec3(0.98, 0.84, 0.26));
col = mix(topo * (0.45 + 0.65 * diff), ordCol * 1.35, inRiver);
} else {
// Right: Full 3D alpine valley landscape synthesized from the hydrology tree
float slope = 1.0 - n.y;
vec3 forest = vec3(0.14, 0.36, 0.18);
vec3 rock = vec3(0.42, 0.40, 0.38);
vec3 snow = vec3(0.92, 0.95, 0.98);
vec3 alb = mix(forest, rock, smoothstep(0.16, 0.42, slope));
alb = mix(alb, snow, smoothstep(0.38, 0.68, hC) * smoothstep(0.48, 0.18, slope));
vec3 riverCol = vec3(0.08, 0.52, 0.72);
alb = mix(alb, riverCol, inRiver);
float spec = pow(max(dot(n, normalize(sunDir - rd)), 0.0), 40.0) * inRiver;
col = alb * (0.24 + 0.88 * diff) + vec3(0.95, 0.98, 1.0) * spec * 0.85;
}
col = mix(col, sky, 1.0 - exp(-t * 0.07));
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| hydrology-terrain-synthesis-live | Tesla T4 1920x1080 | 40.9× baseline (heavy) · 1.34 ms / 1.45 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| hydrology-terrain-synthesis-live | NVIDIA L4 1920x1080 | 34.9× baseline (heavy) · 0.555 ms / 0.557 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| hydrology-terrain-synthesis-live | NVIDIA A100-SXM4-40GB 1920x1080 | 27.2× baseline (heavy) · 0.783 ms / 0.790 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Fractal Brownian Motion and Multifractals.
Crosses
- Interactive Hydraulic Erosion on Heightfields: The river-consistent heightfield gets small-scale gullies and deposits from a short erosion pass.
Sources
- primaryJean-David Génevaux, Éric Galin, Eric Guérin, Adrien Peytavie, Bedrich Benes (2013). Terrain generation using procedural models based on hydrology. ACM Transactions on Graphics.Verified via crossref · 2026-11-29doi:10.1145/2461912.2461996