{
 "id": "ecosystem-plant-distribution",
 "title": "Plant Ecosystem Distribution Simulation",
 "aliases": [
  "ecosystem simulation for vegetation",
  "competition-based plant placement"
 ],
 "domain": "procgen",
 "subdomain": "plants and vegetation",
 "stage": "procedural",
 "realtime": "offline",
 "platforms": [
  "cpu",
  "python",
  "houdini"
 ],
 "year_introduced": 1998,
 "inputs": [
  "heightfield",
  "texture"
 ],
 "outputs": [
  "point-cloud",
  "layout"
 ],
 "style": "photoreal",
 "dynamic": "static",
 "summary": "Places thousands of plants on terrain by simulating seeding, competition for light and space, and survival across plant generations, so species cluster in ecologically plausible patterns.",
 "how_it_works": "Deussen et al. couple a procedural plant model with a population simulation. Starting from an initial set of plants, the simulation iterates over years: plants seed new individuals nearby with dispersion depending on species, each plant's growth and survival depend on its neighbours' shading and root competition and on terrain conditions such as height and moisture, and weaker plants die. Efficiency comes from sorting plants and using only the dominant competitor near each plant. The output is a distribution of species, ages and sizes, which is then rendered with LOD, billboard clouds or geometry instancing. Variants replace the individual-based loop with density maps and procedural rules for speed.",
 "when_to_use": "Choose it for natural-looking vegetation layouts where species mix, age distribution and clearings matter (forests, meadows). Prefer `poisson-disk-sampling` for fast, uniform blue-noise placement when ecology doesn't matter, and `map-elites` or `infinigen` pipelines if the placement is part of a larger scene-generation system.",
 "cost": {
  "class": "offline",
  "notes": "Simulation over many plants and years; practical for 100k+ plants in the original work but scales superlinearly with density."
 },
 "failure_modes": [
  "Parameters (competition radii, seeding distance) need ecological calibration or the simulation yields monocultures",
  "Terrain suitability maps (moisture, sunlight) need to be provided or the species distribution is flat",
  "Simulated output is a static snapshot: no seasonal change or disturbance unless modelled",
  "Renderer must handle massive instance counts; the plant distribution is only half of the problem"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/280814.280898",
   "type": "paper",
   "title": "Realistic modeling and rendering of plant ecosystems",
   "authors": [
    "Oliver Deussen",
    "Pat Hanrahan",
    "Bernd Lintermann",
    "Radomír Měch",
    "Matt Pharr",
    "Przemyslaw Prusinkiewicz"
   ],
   "year": 1998,
   "venue": "Proceedings of the 25th annual conference on Computer graphics and interactive techniques  - SIGGRAPH '98",
   "url": "https://doi.org/10.1145/280814.280898",
   "ids": {
    "doi": "10.1145/280814.280898"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/280814.280898",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/280814.280898",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/280814.280898",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/280814.280898",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/280814.280898",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "deussen1998realistic"
  }
 ],
 "presets": [
  {
   "id": "ecosystem-plant-distribution-live",
   "title": "Plant Ecosystem Distribution — Poisson competition radii & biomes (left) vs self-thinned forest canopy (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_MOISTURE": 0.72,
    "P_COMPETE_R": 0.85,
    "P_TREE_SCALE": 8.5,
    "P_SPLIT": 0.46
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_MOISTURE = 0.72; // P Valley Moisture [0.15, 1.2, 0.04]\nconst float P_COMPETE_R = 0.85; // P Canopy Competition [0.3, 1.3, 0.04]\nconst float P_TREE_SCALE = 8.5; // P Stand Density [5.0, 14.0, 0.5]\nconst float P_SPLIT = 0.46; // P Radii / Forest Split [0.0, 1.0, 0.02]\n\nvec2 hash22(vec2 p) {\n  vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n  p3 += dot(p3, p3.yzx + 33.33);\n  return fract((p3.xx + p3.yz) * p3.zy);\n}\n\n// Terrain elevation & river moisture field across the valley map\nvec2 evalSite(vec2 uv, float moistGain) {\n  float river = abs(uv.x - 0.14 * sin(uv.y * 5.2 + 0.4));\n  float elev = clamp(0.12 + river * 1.15 + 0.18 * sin(uv.x * 4.2) * cos(uv.y * 3.8), 0.0, 1.0);\n  float moist = clamp(exp(-river * 4.5) * moistGain + 0.15 * (1.0 - elev), 0.0, 1.0);\n  return vec2(elev, moist);\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  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool isDiagram = screenX < split;\n  float moistG = clamp(P_MOISTURE, 0.1, 1.4);\n  float compR = clamp(P_COMPETE_R, 0.25, 1.4);\n  float dens = clamp(P_TREE_SCALE, 4.5, 16.0);\n\n  // Subtle slow drift over the watershed ecosystem\n  vec2 worldUV = uv + vec2(0.0, iTime * 0.035);\n  vec2 site = evalSite(worldUV, moistG);\n  float elev = site.x;\n  float moist = site.y;\n\n  // Base terrain soil & alpine contour backdrop\n  vec3 soil = mix(vec3(0.24, 0.30, 0.16), vec3(0.46, 0.42, 0.36), smoothstep(0.42, 0.85, elev));\n  // Valley river strip\n  float inRiver = smoothstep(0.068, 0.038, abs(worldUV.x - 0.14 * sin(worldUV.y * 5.2 + 0.4)));\n  vec3 riverCol = vec3(0.10, 0.46, 0.68);\n  vec3 col = mix(soil, riverCol, inRiver);\n  // Subtle elevation contour lines\n  float contour = smoothstep(0.05, 0.012, abs(fract(elev * 9.0) - 0.5));\n  col = mix(col, vec3(0.12, 0.16, 0.20), contour * (isDiagram ? 0.45 : 0.14));\n\n  // Self-thinning Poisson-disk multi-species stand evaluation over 3x3 cell neighborhood\n  vec2 g = worldUV * dens;\n  vec2 cell = floor(g);\n  vec2 sunDir = normalize(vec2(0.65, 0.76));\n\n  for (int dy = -1; dy <= 1; dy++) {\n    for (int dx = -1; dx <= 1; dx++) {\n      vec2 nc = cell + vec2(float(dx), float(dy));\n      vec2 rnd = hash22(nc);\n      vec2 treePos = (nc + 0.18 + 0.64 * rnd) / dens;\n      vec2 tSite = evalSite(treePos, moistG);\n      float tElev = tSite.x;\n      float tMoist = tSite.y;\n\n      // Skip plants falling directly into river channel or barren rocky peaks\n      float dRiv = abs(treePos.x - 0.14 * sin(treePos.y * 5.2 + 0.4));\n      if (dRiv < 0.055 || tElev > 0.88) continue;\n\n      // Species selection by niche suitability (elev, moisture) + self-thinning dominance radius!\n      // 0 = riparian willow/alder (wet lowland), 1 = broadleaf oak (mid valley), 2 = alpine conifer (high dry ridge)\n      float species = (tMoist > 0.46) ? 0.0 : ((tElev < 0.52) ? 1.0 : 2.0);\n      float age = 0.45 + 0.55 * hash22(nc + 19.3).x;\n      float canopyR = (species < 0.5 ? 0.42 : (species < 1.5 ? 0.50 : 0.34)) * age * compR / dens;\n\n      vec2 diffP = worldUV - treePos;\n      float d = length(diffP);\n\n      if (isDiagram) {\n        // Left: Ecological competition circles, trunk dots & species-coded dominance rings\n        vec3 spCol = (species < 0.5) ? vec3(0.20, 0.92, 0.84)\n                   : (species < 1.5 ? vec3(0.96, 0.74, 0.22) : vec3(0.46, 0.88, 0.32));\n        float ring = exp(-abs(d - canopyR) * 180.0);\n        float fill = smoothstep(canopyR, canopyR * 0.85, d) * 0.22;\n        float dotC = smoothstep(0.010, 0.004, d);\n        col = mix(col, spCol, fill);\n        col += spCol * ring * 0.92;\n        col = mix(col, vec3(0.98, 0.99, 1.0), dotC);\n      } else {\n        // Right: Rendered sunlit multi-species forest crowns with soft drop shadows!\n        float dShad = length(diffP + sunDir * canopyR * 0.55);\n        col *= mix(1.0, 0.62, smoothstep(canopyR * 1.05, canopyR * 0.6, dShad));\n\n        // Scalloped organic crown silhouette\n        float ang = atan(diffP.y, diffP.x);\n        float scallop = 1.0 + 0.12 * sin(ang * (species > 1.5 ? 9.0 : 5.0) + rnd.x * 6.28);\n        float rEff = canopyR * scallop;\n        if (d < rEff) {\n          float hCrown = sqrt(max(1.0 - (d / max(rEff, 1e-4)) * (d / max(rEff, 1e-4)), 0.0));\n          vec3 nCrown = normalize(vec3(diffP / max(rEff, 1e-4), hCrown));\n          float lit = max(dot(nCrown, normalize(vec3(sunDir, 0.85))), 0.0);\n          vec3 spCol = (species < 0.5) ? vec3(0.24, 0.66, 0.34)\n                     : (species < 1.5 ? mix(vec3(0.32, 0.56, 0.16), vec3(0.76, 0.54, 0.16), rnd.y)\n                                      : vec3(0.08, 0.32, 0.22));\n          col = spCol * (0.28 + 0.90 * lit);\n        }\n      }\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "ecosystem-plant-distribution",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T20:35:48.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.7049,
      "std": 0.082,
      "min": 0.3104,
      "max": 0.9443
     },
     "image": "/specimens/ecosystem-plant-distribution-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "poisson-disk-sampling",
  "l-systems",
  "space-colonization-trees",
  "infinigen"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "space-colonization-trees",
   "why": "The ecosystem simulation chooses which species goes where; tree generators supply the geometry."
  }
 ],
 "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/ecosystem-plant-distribution.json"
 },
 "solves": [
  "scattered trees look random and unnatural",
  "forest needs species mix, clearings and age variety",
  "plants should compete for light and space realistically",
  "placing thousands of plants by hand is impractical"
 ],
 "authority": "Deussen et al., 1998",
 "url": "https://texelatlas.vercel.app/t/ecosystem-plant-distribution/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 18.56,
  "tier": "moderate",
  "p50_ms": 0.6106,
  "p95_ms": 0.6488,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "ecosystem-plant-distribution-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 16.92,
   "tier": "moderate",
   "p50_ms": 0.2691,
   "p95_ms": 0.2719,
   "speedup_x": 2.27,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 13.38,
   "tier": "moderate",
   "p50_ms": 0.3853,
   "p95_ms": 0.3875,
   "speedup_x": 1.58,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}