In this lesson, you will learn how to breathe life into static foliage by using noise textures and time-based math to procedurally animate vertex positions.
The Logic of Foliage Motion
To simulate realistic wind, we manipulate the Position of vertices within the Vertex Stage of your Shader Graph. Instead of animating meshes manually, we create a "wind wave" by offsetting each vertex along its normal or world-space axis using a combination of Time and a seamless Simple Noise texture.
Implementing the Displacement
The core of this technique relies on sampling a noise texture using world-space coordinates. By scrolling the UVs of the noise texture over time, you create a flowing pattern. We then multiply this noise value by a Vertex Color mask (usually painted on the model to keep the trunk static while the leaves move) and add the result to the original vertex position.
Here is the logic flow you should implement in your graph:
- Time: Multiply
Timeby aWindSpeedproperty to control the flow. - Noise: Plug your time-offset UVs into a
Simple Noisenode to generate the wind pattern. - Masking: Multiply the Noise output by the
Vertex Color(specifically the Red channel) to ensure only the canopy moves. - Displacement: Use an
Addnode to combine your originalPosition (Object Space)with the result of your noise calculation (multiplied by aWindStrengthproperty). - Output: Connect this to the
Vertex Positionslot on your Master Node.
// Conceptual Shader Logic
float3 windOffset = SimpleNoise(WorldPos.xz + Time) * VertexColor.r * WindStrength;
VertexPosition = ObjectPos + windOffset;
Pro-Tip for Realism
To avoid the foliage looking like a vibrating blob, use a Lerp node to mix between two different noise scales—a large scale for the "swaying" of branches and a fine, high-frequency scale for the "fluttering" of individual leaves. By keeping your displacement in World Space, the wind will appear consistent across the entire forest regardless of where individual trees are placed.
Key Takeaway: By using world-space noise scaled by vertex colors and time, you can drive complex, organic foliage animation without the performance overhead of skeletal skinning.