---
id: "foliage-wind-animation"
title: "Procedural foliage wind animation"
aliases: [vertex wind, tree sway, grass sway, vegetation wind]
domain: "simulation"
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"
cost: "cheap"
authority: "Zadeh"
url: "https://texelatlas.vercel.app/t/foliage-wind-animation/"
sources_verified_at: "2026-11-29"
---
# Procedural foliage wind animation (Zadeh)

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

## Reach for it when

- 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

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

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 with relaxation constraints](https://texelatlas.vercel.app/t/verlet-integration-constraints.md) or [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md) when branches must react to colliders or the player, and [Vertex animation textures (VAT) and GPU crowds](https://texelatlas.vercel.app/t/vertex-animation-textures.md) when you need a baked, unique motion on a few hero assets. Prefer [Curl noise for procedural fluid motion](https://texelatlas.vercel.app/t/curl-noise-flow.md) as the wind source when you want swirling, non-directional gusts. Pair with [Octahedral impostors](https://texelatlas.vercel.app/t/octahedral-impostors.md) for distant trees so the sway fades out with distance.

## Cost

cheap — A few sine or texture lookups per vertex; no extra passes beyond matching the shadow pass.
Measured GPU Weight: 13.32× baseline (moderate) — 0.4382 ms median / 0.4564 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 12.99× baseline (moderate) — 0.2065 ms median (2.12× faster on L4).
Ampere A100 scaling: 9.51× baseline (moderate) — 0.2738 ms median (1.6× faster on A100).

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

## Engine support

- unity: builtin — `GameObject > 3D Object > Wind Zone (bends Terrain trees and SpeedTree)` (evidence: https://docs.unity3d.com/6000.0/Documentation/Manual/class-WindZone.html, checked 2026-12-01) — Tree wind only; grass and custom meshes need shaders.
- unreal: builtin — `Material graph: SimpleGrassWind material function into World Position Offset` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/world-position-offset-material-functions-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: mesh, texture
- Outputs: mesh, animation
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot

## Presets

### 2D grass-blade sway with travelling gusts (glsl-fragment; rendered 2026-11-29)

```json
{
  "spacing": 0.045,
  "blade_height": 0.35,
  "wind": 0.12,
  "wave_freq": 6,
  "wave_speed": 2,
  "flutter": 0.012
}
```

```glsl
// GLSL ES 3.0, Shadertoy-style. 2D grass-blade sway: bend grows with height squared, a travelling gust plus fast flutter.
const float SPACING   = 0.045;  // blade pitch
const float BLADE_H   = 0.35;   // blade height
const float WIND      = 0.12;   // peak tip displacement of the main bend
const float WAVE_FREQ = 6.0;    // gust wave number along x
const float WAVE_SPD  = 2.0;    // gust travel speed
const float FLUTTER   = 0.012;  // small high-frequency tip shake
const float GROUND    = -0.3;

float hash11(float n) { return fract(sin(n * 127.1) * 43758.5453); }

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    vec3 col = mix(vec3(0.80, 0.90, 0.98), vec3(0.30, 0.55, 0.90), uv.y + 0.5);
    for (int layer = 0; layer < 3; layer++) {
        float fl = float(layer);
        float shade = 0.45 + 0.28 * fl;
        float cell = floor(uv.x / SPACING + fl * 0.37);
        for (int k = -3; k <= 3; k++) {
            float id = cell + float(k) + fl * 91.0;
            float cx = (id + 0.5 + (hash11(id) - 0.5) * 0.6 - fl * 0.37) * SPACING;
            float height = BLADE_H * (0.6 + 0.6 * hash11(id + 17.0));
            float h = (uv.y - GROUND) / height;
            if (h < 0.0 || h > 1.0) continue;
            float gust = 0.5 + 0.5 * sin(WAVE_FREQ * cx - WAVE_SPD * iTime);
            float bend = WIND * h * h * (0.25 + 0.75 * gust);
            bend += FLUTTER * h * h * sin(11.0 * iTime + hash11(id + 3.0) * 6.28);
            float halfW = 0.011 * (1.0 - 0.85 * h);
            if (abs(uv.x - (cx + bend)) < halfW)
                col = vec3(0.10, 0.45, 0.12) * shade + vec3(0.25, 0.35, 0.05) * h * shade;
        }
    }
    if (uv.y < GROUND) col = vec3(0.16, 0.11, 0.07) * (1.0 + 0.5 * (uv.y - GROUND));
    fragColor = vec4(col, 1.0);
}
```

Attribution: written for this index

## Combines with

- [Curl noise for procedural fluid motion](https://texelatlas.vercel.app/t/curl-noise-flow.md): A scrolling curl-noise field supplies the wind vector each vertex samples, producing swirling gusts that stay incompressible.
- [Octahedral impostors](https://texelatlas.vercel.app/t/octahedral-impostors.md): Distant trees swap to impostors, so the wind amplitude is faded toward zero before the swap to hide the transition.

## Sources

1. [primary] Zadeh GPU Gems 3, Chapter 6: GPU-Generated Procedural Wind Animations for Trees. developer.nvidia.com. https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-6-gpu-generated-procedural-wind-animations-trees (verified via http on 2026-11-29)
2. [tutorial] Sousa GPU Gems 3, Chapter 16: Vegetation Procedural Animation and Shading in Crysis. developer.nvidia.com. https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-16-vegetation-procedural-animation-and-shading-crysis (verified via http on 2026-11-29)

## Cite this entry

Texel. "Procedural foliage wind animation." https://texelatlas.vercel.app/t/foliage-wind-animation/ (accessed 2026-12-01).
