{
 "id": "stream-power-erosion",
 "title": "Stream-Power Erosion (Fluvial Terrain Uplift)",
 "aliases": [
  "stream power law",
  "uplift-erosion",
  "fluvial erosion terrain"
 ],
 "domain": "procgen",
 "subdomain": "terrain erosion",
 "stage": "procedural",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "desktop-gpu",
  "python",
  "houdini",
  "unity",
  "unreal"
 ],
 "year_introduced": 2016,
 "inputs": [
  "heightfield",
  "graph"
 ],
 "outputs": [
  "heightfield"
 ],
 "style": "photoreal",
 "dynamic": "static",
 "summary": "Generates mountain ranges by evolving a heightfield under tectonic uplift and the stream-power law, in which erosion rate depends on drainage area and slope, producing coherent river networks and ridges at large scale.",
 "how_it_works": "The terrain evolves as dh/dt = U - K A^m S^n: uplift U raises the surface while erosion removes material proportional to upstream drainage area A and slope S raised to empirical exponents. Each iteration computes flow direction (steepest descent on a graph), accumulates drainage area from high to low, and applies an implicit update that is unconditionally stable even for large timesteps. Because uplift is a user-paintable map, authors sketch where mountains rise and the erosion then carves a consistent valley network. Cordonnier and colleagues use this to go from a coarse uplift sketch to realistic ranges with only tens of iterations, and note it works naturally on regular grids, triangulations or quadtrees. Pits must be resolved so every cell drains to a sink.",
 "when_to_use": "Choose it for continental or mountain-range scale terrain where drainage consistency matters, and when artists need to paint uplift rather than tune droplet counts. Prefer `hydraulic-erosion-stava` or `gpu-pipe-model-erosion` for local gullies and deposition detail, and `hydrology-terrain-synthesis` when you want to sketch the river network first.",
 "cost": {
  "class": "offline",
  "notes": "Each iteration is a graph pass over all cells (flow routing plus an area accumulation); tens of iterations suffice, so seconds to minutes depending on resolution."
 },
 "failure_modes": [
  "Local minima/lakes produce terraces unless depressions are filled or breached before routing",
  "Single-direction (D8) flow gives blocky, grid-aligned river courses",
  "Pure detachment-limited law yields no sediment deposition, so there are no alluvial fans or flat valley floors",
  "Exponents m,n and K per rock type must be chosen together; bad values give sawtooth ridges or flat plateaus",
  "Resolution-dependent drainage threshold changes river density"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1111/cgf.12820",
   "type": "paper",
   "title": "Large Scale Terrain Generation from Tectonic Uplift and Fluvial Erosion",
   "authors": [
    "Guillaume Cordonnier",
    "Jean Braun",
    "Marie‐Paule Cani",
    "Bedrich Benes",
    "Éric Galin",
    "Adrien Peytavie",
    "Éric Guérin"
   ],
   "year": 2016,
   "venue": "Computer Graphics Forum",
   "url": "https://doi.org/10.1111/cgf.12820",
   "ids": {
    "doi": "10.1111/cgf.12820"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.12820",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.12820",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.12820",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.12820",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.12820",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "cordonnier2016large"
  },
  {
   "role": "implementation",
   "key": "gh:h-schott/streampowererosion",
   "type": "code",
   "title": "H-Schott/StreamPowerErosion",
   "description": "Large-Scale Stream Power Erosion",
   "authors": [
    "H-Schott"
   ],
   "year": 2023,
   "venue": "GitHub",
   "url": "https://github.com/H-Schott/StreamPowerErosion",
   "ids": {
    "repo": "H-Schott/StreamPowerErosion"
   },
   "license": "MIT",
   "extra": {
    "stars": 52,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-09-17T15:03:39Z",
    "language": "C++",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/H-Schott/StreamPowerErosion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/H-Schott/StreamPowerErosion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/H-Schott/StreamPowerErosion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/H-Schott/StreamPowerErosion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/H-Schott/StreamPowerErosion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/H-Schott/StreamPowerErosion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "hschott2023schott"
  }
 ],
 "presets": [
  {
   "id": "stream-power-erosion-live",
   "title": "Stream-power erosion — tectonic uplift & dendritic fluvial drainage carving",
   "runtime": "glsl-fragment",
   "params": {
    "P_UPLIFT": 1.15,
    "P_INCISION": 0.95,
    "P_SNOWLINE": 0.56,
    "P_SUN_ELEV": 0.45
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_UPLIFT = 1.15; // P Tectonic Uplift [0.4, 2.0, 0.05]\nconst float P_INCISION = 0.95; // P Fluvial Incision [0.0, 1.8, 0.05]\nconst float P_SNOWLINE = 0.56; // P Snowline Elev [0.2, 1.0, 0.02]\nconst float P_SUN_ELEV = 0.45; // P Sun Elevation [0.1, 1.2, 0.02]\n\nvec2 hash22(vec2 p) {\n  p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));\n  return fract(sin(p) * 43758.5453);\n}\n\n// Sharp Voronoi ridge distance (models dendritic drainage divides & carved river valleys)\nfloat voronoiRidge(vec2 p) {\n  vec2 n = floor(p);\n  vec2 f = fract(p);\n  float d1 = 8.0, d2 = 8.0;\n  for (int j = -1; j <= 1; j++) {\n    for (int i = -1; i <= 1; i++) {\n      vec2 g = vec2(float(i), float(j));\n      vec2 o = 0.18 + 0.64 * hash22(n + g);\n      vec2 r = g + o - f;\n      float d = dot(r, r);\n      if (d < d1) { d2 = d1; d1 = d; }\n      else if (d < d2) { d2 = d; }\n    }\n  }\n  return sqrt(d2) - sqrt(d1);\n}\n\n// Stream-power law steady-state terrain: uplift minus multi-scale dendritic fluvial incision\nvec2 evalTerrain(vec2 p, float uplift, float incise) {\n  // Macro tectonic dome\n  float base = 0.65 * exp(-dot(p, p) * 0.095) + 0.22 * sin(p.x * 0.55) * cos(p.y * 0.52);\n\n  // Hierarchical dendritic drainage network (3 octaves of warped V-valleys)\n  vec2 q = p * 0.62;\n  float r1 = voronoiRidge(q + 0.18 * vec2(sin(q.y * 1.9), cos(q.x * 1.7)));\n  float r2 = voronoiRidge(q * 2.15 + vec2(3.1, 1.7) + 0.22 * vec2(cos(q.y * 3.1), sin(q.x * 2.8)));\n  float r3 = voronoiRidge(q * 4.4 - vec2(2.4, 4.1));\n\n  // Concave stream-power profile: smooth steep ridges, sharp incised V-valleys (A^m * S^n)\n  float ridge1 = 1.0 - exp(-r1 * 2.6);\n  float ridge2 = 1.0 - exp(-r2 * 2.8);\n  float ridge3 = 1.0 - exp(-r3 * 3.0);\n\n  float carved = 0.56 * ridge1 + 0.28 * ridge2 * (0.35 + 0.65 * ridge1) + 0.14 * ridge3 * ridge2;\n  float h = uplift * mix(base + 0.35, (base + 0.22) * (0.28 + 1.05 * carved), clamp(incise, 0.0, 1.6));\n\n  // Drainage accumulation proxy (highest along primary/secondary valley floors)\n  float streamMask = exp(-r1 * 18.0) + 0.45 * exp(-r2 * 20.0) * smoothstep(0.35, 0.05, r1);\n  return vec2(h, streamMask);\n}\n\nvec3 terrainNormal(vec2 p, float uplift, float incise) {\n  float e = 0.025;\n  float hx = evalTerrain(p + vec2(e, 0.0), uplift, incise).x - evalTerrain(p - vec2(e, 0.0), uplift, incise).x;\n  float hz = evalTerrain(p + vec2(0.0, e), uplift, incise).x - evalTerrain(p - vec2(0.0, e), uplift, incise).x;\n  return normalize(vec3(-hx, 2.0 * e, -hz));\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n\n  float uplift = clamp(P_UPLIFT, 0.35, 2.2);\n  float incise = clamp(P_INCISION, 0.0, 1.8);\n  float snowH = clamp(P_SNOWLINE, 0.15, 1.2);\n  float sunEl = clamp(P_SUN_ELEV, 0.08, 1.3);\n\n  float camAng = iTime * 0.18 + 0.4;\n  vec3 ro = vec3(sin(camAng) * 3.55, 1.92, cos(camAng) * 3.55);\n  vec3 ta = vec3(0.0, 0.42, 0.0);\n  vec3 ww = normalize(ta - ro);\n  vec3 uu = normalize(cross(ww, vec3(0.0, 1.0, 0.0)));\n  vec3 vv = cross(uu, ww);\n  vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.5 * ww);\n\n  vec3 sunDir = normalize(vec3(cos(0.7 + iTime * 0.15), sunEl, sin(0.7 + iTime * 0.15)));\n\n  // Crisp alpine sky\n  vec3 skyCol = mix(vec3(0.78, 0.84, 0.90), vec3(0.18, 0.40, 0.72), pow(max(rd.y, 0.0), 0.55));\n  skyCol += vec3(1.0, 0.86, 0.62) * pow(max(dot(rd, sunDir), 0.0), 40.0) * 0.9;\n  vec3 col = skyCol;\n\n  float t = 0.8;\n  bool hit = false;\n  vec2 th = vec2(0.0);\n  for (int i = 0; i < 64; i++) {\n    vec3 p = ro + rd * t;\n    th = evalTerrain(p.xz, uplift, incise);\n    float d = p.y - th.x;\n    if (d < 0.008 * t) { hit = true; break; }\n    t += max(0.04, d * 0.48);\n    if (t > 14.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    th = evalTerrain(p.xz, uplift, incise);\n    vec3 n = terrainNormal(p.xz, uplift, incise);\n    float slope = 1.0 - clamp(n.y, 0.0, 1.0);\n\n    // Terrain shadow march\n    float sh = 1.0;\n    float st = 0.08;\n    for (int s = 0; s < 16; s++) {\n      vec3 sp = p + sunDir * st;\n      float sd = sp.y - evalTerrain(sp.xz, uplift, incise).x;\n      sh = min(sh, clamp(4.0 * sd / st, 0.0, 1.0));\n      st += max(0.06, sd * 0.55);\n      if (st > 3.5 || sh < 0.05) break;\n    }\n\n    // Geomorphological biomes: alluvial green valleys -> granite scree -> alpine snow ridges\n    vec3 valleyCol = vec3(0.14, 0.28, 0.12);\n    vec3 rockCol = mix(vec3(0.28, 0.25, 0.22), vec3(0.46, 0.42, 0.38), smoothstep(0.15, 0.65, th.x));\n    vec3 snowCol = vec3(0.92, 0.95, 0.99);\n\n    float rockMask = smoothstep(0.12, 0.34, slope + th.x * 0.22);\n    vec3 alb = mix(valleyCol, rockCol, rockMask);\n    float snowMask = smoothstep(snowH - 0.08, snowH + 0.14, th.x - slope * 0.38);\n    alb = mix(alb, snowCol, snowMask);\n\n    // Fluvial streams carving glowing turquoise ribbons through valley drainage channels\n    float river = smoothstep(0.45, 0.95, th.y * incise) * smoothstep(snowH + 0.15, 0.25, th.x);\n    vec3 riverCol = vec3(0.08, 0.48, 0.62);\n\n    float ndl = max(dot(n, sunDir), 0.0);\n    vec3 lit = alb * (vec3(2.25, 1.88, 1.38) * ndl * (0.08 + 0.92 * sh) + vec3(0.14, 0.24, 0.42) * (0.25 + 0.75 * n.y));\n\n    // Water specular sparkle in incised channels\n    vec3 hVec = normalize(sunDir - rd);\n    float rSpec = pow(max(dot(vec3(0.0, 1.0, 0.0), hVec), 0.0), 48.0) * 1.8 * sh;\n    vec3 riverLit = riverCol * (0.35 + 0.9 * ndl * sh) + vec3(0.95, 0.98, 1.0) * rSpec;\n    lit = mix(lit, riverLit, clamp(river, 0.0, 0.92));\n\n    // Aerial perspective haze\n    float fog = 1.0 - exp(-0.045 * t * t * 0.25);\n    col = mix(lit, skyCol * 0.92, clamp(fog, 0.0, 0.85));\n  }\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "stream-power-erosion",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:50:13.852Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.8276,
      "std": 0.1166,
      "unique_colors": 334
     },
     "image": "/specimens/stream-power-erosion-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "hydraulic-erosion-stava",
  "gpu-pipe-model-erosion",
  "hydrology-terrain-synthesis",
  "thermal-erosion",
  "fractal-brownian-motion"
 ],
 "extends": [
  "hydrology-terrain-synthesis"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "fractal-brownian-motion",
   "why": "A noise-perturbed initial surface avoids flat starts and seeds drainage randomly."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/procgen/stream-power-erosion.json"
 },
 "solves": [
  "fbm mountains lack believable river networks",
  "need continental-scale terrain with coherent drainage",
  "want artists to paint uplift to shape ranges",
  "droplet erosion doesn't scale to large maps"
 ],
 "authority": "Cordonnier et al., 2016",
 "url": "https://texelatlas.vercel.app/t/stream-power-erosion/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 621.98,
  "tier": "extreme",
  "p50_ms": 20.463,
  "p95_ms": 20.5022,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 20,
  "preset_id": "stream-power-erosion-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 514.06,
   "tier": "extreme",
   "p50_ms": 8.1736,
   "p95_ms": 8.2454,
   "speedup_x": 2.5,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 338.72,
   "tier": "extreme",
   "p50_ms": 9.7551,
   "p95_ms": 9.8198,
   "speedup_x": 2.1,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}