---
id: "hydrology-terrain-synthesis"
title: "Terrain from Hydrology (River-First Terrain Synthesis)"
aliases: [procedural terrain from river networks]
domain: "procgen"
stage: "procedural"
realtime: "interactive"
platforms: [cpu, desktop-gpu, python, houdini]
year_introduced: 2013
inputs: [graph]
outputs: [heightfield]
style: "photoreal"
dynamic: "static"
cost: "medium"
authority: "Génevaux et al., 2013"
url: "https://texelatlas.vercel.app/t/hydrology-terrain-synthesis/"
sources_verified_at: "2026-11-29"
---
# Terrain from Hydrology (River-First Terrain Synthesis) (Génevaux et al., 2013)

> 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.

## 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

## 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 use it

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)](https://texelatlas.vercel.app/t/stream-power-erosion.md) when you want the river network to emerge from uplift rather than be drawn, and [Interactive Hydraulic Erosion on Heightfields](https://texelatlas.vercel.app/t/hydraulic-erosion-stava.md) for fine erosion detail on top.

## Cost

medium — Graph construction plus an interpolation pass over the grid; far cheaper than iterating full erosion.
Measured GPU Weight: 40.86× baseline (heavy) — 1.3444 ms median / 1.4474 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 34.88× baseline (heavy) — 0.5546 ms median (2.42× faster on L4).
Ampere A100 scaling: 27.2× baseline (heavy) — 0.7834 ms median (1.72× faster on A100).

## Failure modes

- 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

## Dataflow

- Inputs: graph
- Outputs: heightfield
- Platforms: cpu, desktop-gpu, python, houdini

## Presets

### Hydrology Terrain Synthesis — Strahler river-tree & watershed map (left) vs uplifted alpine valleys (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_UPLIFT": 0.92,
  "P_RIVER_WIDTH": 0.85,
  "P_CAM_SWAY": 0.42,
  "P_SPLIT": 0.46
}
```

```glsl
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.

## Lineage

- extended by [Stream-Power Erosion (Fluvial Terrain Uplift)](https://texelatlas.vercel.app/t/stream-power-erosion.md)

## Combines with

- [Interactive Hydraulic Erosion on Heightfields](https://texelatlas.vercel.app/t/hydraulic-erosion-stava.md): The river-consistent heightfield gets small-scale gullies and deposits from a short erosion pass.

## Sources

1. [primary] Jean-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. https://doi.org/10.1145/2461912.2461996 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "Terrain from Hydrology (River-First Terrain Synthesis)." https://texelatlas.vercel.app/t/hydrology-terrain-synthesis/ (accessed 2026-12-01).
