{
 "id": "foliage-wind-animation",
 "title": "Procedural foliage wind animation",
 "aliases": [
  "vertex wind",
  "tree sway",
  "grass sway",
  "vegetation wind"
 ],
 "domain": "simulation",
 "subdomain": "vegetation animation",
 "stage": "simulation",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2007,
 "inputs": [
  "mesh",
  "texture"
 ],
 "outputs": [
  "mesh",
  "animation"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "Move vegetation in the vertex shader with layered trunk bend, branch sway and leaf flutter, steered by a global wind direction and masked by painted vertex data.",
 "how_it_works": "Wind is treated as a scalar or vector field in world space, scrolled over time: a sum of low-frequency sines or a tiling noise texture gives gusts that travel across the scene. Each vertex reads that field at its world position and applies several displacement bands. A main bend moves the whole plant with a weight that rises with height, usually squared so the base stays rooted. A branch band offsets groups of vertices with a phase stored per branch so limbs do not move in lockstep. A detail band shakes leaves with high-frequency noise along the normal and edge, keyed to a per-vertex phase. The masks live in vertex colours or UVs: height weight, branch phase, leaf flutter amount. Displacements are applied as rotations or length-preserving offsets, not raw translations, to avoid stretching. Shadow and depth passes must run the same function so shadows follow the sway.",
 "when_to_use": "Choose it for grass, trees, bushes and flags in open scenes, where cost per vertex must stay tiny and the animation is ambient. Prefer `verlet-integration-constraints` or `xpbd` when branches must react to colliders or the player, and `vertex-animation-textures` when you need a baked, unique motion on a few hero assets. Prefer `curl-noise-flow` as the wind source when you want swirling, non-directional gusts. Pair with `octahedral-impostors` for distant trees so the sway fades out with distance.",
 "cost": {
  "class": "cheap",
  "notes": "A few sine or texture lookups per vertex; no extra passes beyond matching the shadow pass."
 },
 "failure_modes": [
  "Shadow-map and depth prepass geometry not animated identically, so shadows and outlines detach from the foliage",
  "Raw translation stretches leaves and trunks; bending should preserve length",
  "Synchronised phase makes the whole field pulse like a wave machine; per-instance and per-branch phase offsets are required",
  "Normals not rotated with the bend cause lighting to flicker on sway",
  "Wind field not distance-faded to LOD or impostors leaves popping when switching representation"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-6-gpu-generated-procedural-wind-animations-trees",
   "type": "web",
   "title": "GPU Gems 3, Chapter 6: GPU-Generated Procedural Wind Animations for Trees",
   "authors": [
    "Zadeh"
   ],
   "year": null,
   "venue": "developer.nvidia.com",
   "url": "https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-6-gpu-generated-procedural-wind-animations-trees",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260815080643/https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-6-gpu-generated-procedural-wind-animations-trees",
     "timestamp": "20260815080643"
    },
    "page_title": "Chapter 6. GPU-Generated Procedural Wind Animations for Trees",
    "host": "developer.nvidia.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-6-gpu-generated-procedural-wind-animations-trees → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-6-gpu-generated-procedural-wind-animations-trees → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-6-gpu-generated-procedural-wind-animations-trees → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.95,
   "__bib": "zadehgems"
  },
  {
   "role": "tutorial",
   "key": "url:https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-16-vegetation-procedural-animation-and-shading-crysis",
   "type": "tutorial",
   "title": "GPU Gems 3, Chapter 16: Vegetation Procedural Animation and Shading in Crysis",
   "authors": [
    "Sousa"
   ],
   "year": null,
   "venue": "developer.nvidia.com",
   "url": "https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-16-vegetation-procedural-animation-and-shading-crysis",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261113074926/https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-16-vegetation-procedural-animation-and-shading-crysis",
     "timestamp": "20261113074926"
    },
    "page_title": "Chapter 16. Vegetation Procedural Animation and Shading in Crysis",
    "host": "developer.nvidia.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-16-vegetation-procedural-animation-and-shading-crysis → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-16-vegetation-procedural-animation-and-shading-crysis → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-16-vegetation-procedural-animation-and-shading-crysis → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.95,
   "__bib": "sousagems"
  }
 ],
 "presets": [
  {
   "id": "foliage-wind-grass-sway",
   "title": "2D grass-blade sway with travelling gusts",
   "runtime": "glsl-fragment",
   "params": {
    "spacing": 0.045,
    "blade_height": 0.35,
    "wind": 0.12,
    "wave_freq": 6,
    "wave_speed": 2,
    "flutter": 0.012
   },
   "code": "// GLSL ES 3.0, Shadertoy-style. 2D grass-blade sway: bend grows with height squared, a travelling gust plus fast flutter.\nconst float SPACING   = 0.045;  // blade pitch\nconst float BLADE_H   = 0.35;   // blade height\nconst float WIND      = 0.12;   // peak tip displacement of the main bend\nconst float WAVE_FREQ = 6.0;    // gust wave number along x\nconst float WAVE_SPD  = 2.0;    // gust travel speed\nconst float FLUTTER   = 0.012;  // small high-frequency tip shake\nconst float GROUND    = -0.3;\n\nfloat hash11(float n) { return fract(sin(n * 127.1) * 43758.5453); }\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n    vec3 col = mix(vec3(0.80, 0.90, 0.98), vec3(0.30, 0.55, 0.90), uv.y + 0.5);\n    for (int layer = 0; layer < 3; layer++) {\n        float fl = float(layer);\n        float shade = 0.45 + 0.28 * fl;\n        float cell = floor(uv.x / SPACING + fl * 0.37);\n        for (int k = -3; k <= 3; k++) {\n            float id = cell + float(k) + fl * 91.0;\n            float cx = (id + 0.5 + (hash11(id) - 0.5) * 0.6 - fl * 0.37) * SPACING;\n            float height = BLADE_H * (0.6 + 0.6 * hash11(id + 17.0));\n            float h = (uv.y - GROUND) / height;\n            if (h < 0.0 || h > 1.0) continue;\n            float gust = 0.5 + 0.5 * sin(WAVE_FREQ * cx - WAVE_SPD * iTime);\n            float bend = WIND * h * h * (0.25 + 0.75 * gust);\n            bend += FLUTTER * h * h * sin(11.0 * iTime + hash11(id + 3.0) * 6.28);\n            float halfW = 0.011 * (1.0 - 0.85 * h);\n            if (abs(uv.x - (cx + bend)) < halfW)\n                col = vec3(0.10, 0.45, 0.12) * shade + vec3(0.25, 0.35, 0.05) * h * shade;\n        }\n    }\n    if (uv.y < GROUND) col = vec3(0.16, 0.11, 0.07) * (1.0 + 0.5 * (uv.y - GROUND));\n    fragColor = vec4(col, 1.0);\n}",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "foliage-wind-animation",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5091,
      "std": 0.2428,
      "unique_colors": 38
     },
     "image": "/specimens/foliage-wind-grass-sway.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "curl-noise-flow",
  "verlet-integration-constraints",
  "octahedral-impostors",
  "vertex-animation-textures",
  "space-colonization-trees"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "curl-noise-flow",
   "why": "A scrolling curl-noise field supplies the wind vector each vertex samples, producing swirling gusts that stay incompressible."
  },
  {
   "id": "octahedral-impostors",
   "why": "Distant trees swap to impostors, so the wind amplitude is faded toward zero before the swap to hide the transition."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/simulation/foliage-wind-animation.json"
 },
 "solves": [
  "grass and trees need to sway convincingly in the wind",
  "wind animation shadows detach from moving leaves",
  "all plants pulse in sync like a wave machine",
  "want cheap ambient vegetation motion in the vertex shader"
 ],
 "authority": "Zadeh",
 "url": "https://texelatlas.vercel.app/t/foliage-wind-animation/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 13.32,
  "tier": "moderate",
  "p50_ms": 0.4382,
  "p95_ms": 0.4564,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "foliage-wind-grass-sway",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 12.99,
   "tier": "moderate",
   "p50_ms": 0.2065,
   "p95_ms": 0.2068,
   "speedup_x": 2.12,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 9.51,
   "tier": "moderate",
   "p50_ms": 0.2738,
   "p95_ms": 0.2752,
   "speedup_x": 1.6,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}