In this lesson, you will learn how to leverage vertex displacement to simulate organic wind motion while maintaining high frame rates across large-scale foliage deployments.
The Mechanism of Vertex Animation
To breathe life into static foliage without expensive per-leaf skeletal rigs, we manipulate the World Position Offset (WPO) node in the Material Editor. The core concept involves using the WorldPosition of the mesh as an input for a Sine wave, which causes vertices to oscillate in 3D space.
To create "organic" motion, we rely on a SimpleGrassWind node. This function simulates the swaying of grass or leaves by taking a Wind Intensity parameter and a Wind Weight mask. The crucial performance optimization here is the Wind Weight texture (usually stored in the vertex color’s Red channel), which defines where the asset is anchored. By keeping the root of a tree or the base of a blade of grass at a weight of 0, we prevent the entire mesh from floating away, ensuring the movement is tethered to the geometry’s origin.
Implementing Efficient Sway
A basic wind setup looks like this in your Material Graph:
// Simplified logic for WPO node
float3 WorldOffset = SimpleGrassWind(
WorldPosition,
WindIntensity,
WindWeight,
WindSpeed
);
return WorldOffset;
To ensure this doesn't bottleneck the GPU, we follow two strict rules:
- Masking: Always use a grayscale texture (the vertex color map) to mask the WPO. This ensures that only the outer branches or blades move, leaving heavy structural trunks static.
- Precision: By using a single global
Material Parameter Collectionto drive theWindIntensity, you can update the wind behavior for your entire environment in one draw call, rather than individual actor updates.
Because we are operating at the vertex level, this approach is extremely lightweight compared to bones. It allows you to maintain thousands of active, swaying instances, ensuring your environment feels alive without incurring the massive overhead of CPU-side animation.
Key Takeaway: Use masked World Position Offset with SimpleGrassWind to drive vertex-based motion, anchoring your foliage performance by locking non-deformable mesh roots to a Wind Weight value of zero.