Procedural foliage wind animation
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.
Also known as vertex wind, tree sway, grass sway, vegetation wind
In the family Simulation & animation, vegetation animation
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | No built-in procedural foliage wind vertex-shader preset; requires custom ShaderMaterial. |
| Unity | Built in | GameObject > 3D Object > Wind Zone (bends Terrain trees and SpeedTree) docs Tree wind only; grass and custom meshes need shaders. |
| Unreal 5.7 | Built in | Material graph: SimpleGrassWind material function into World Position Offset docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
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 or Extended Position-Based Dynamics when branches must react to colliders or the player, and Vertex animation textures (VAT) and GPU crowds when you need a baked, unique motion on a few hero assets. Prefer Curl noise for procedural fluid motion 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.
Field marks
- 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
Presets
2D grass-blade sway with travelling gusts
{
"spacing": 0.045,
"blade_height": 0.35,
"wind": 0.12,
"wave_freq": 6,
"wave_speed": 2,
"flutter": 0.012
}Show GLSL (35 lines)
// 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
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| foliage-wind-grass-sway | Tesla T4 1920x1080 | 13.3× baseline (moderate) · 0.438 ms / 0.456 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| foliage-wind-grass-sway | NVIDIA L4 1920x1080 | 13.0× baseline (moderate) · 0.206 ms / 0.207 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| foliage-wind-grass-sway | NVIDIA A100-SXM4-40GB 1920x1080 | 9.51× baseline (moderate) · 0.274 ms / 0.275 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Curl noise for procedural fluid motion: A scrolling curl-noise field supplies the wind vector each vertex samples, producing swirling gusts that stay incompressible.
- Octahedral impostors: Distant trees swap to impostors, so the wind amplitude is faded toward zero before the swap to hide the transition.
Sources
- primaryZadeh. GPU Gems 3, Chapter 6: GPU-Generated Procedural Wind Animations for Trees. developer.nvidia.com.Verified via live page · 2026-11-29
- tutorialSousa. GPU Gems 3, Chapter 16: Vegetation Procedural Animation and Shading in Crysis. developer.nvidia.com.Verified via live page · 2026-11-29