Course contentsShow
← Unity Game Development
Lesson 622 of 8289. Rendering and VisualsFree lesson

Creating Vertex Displacement for Foliage Animation

Learn to manipulate vertex positions using noise textures and time nodes to simulate realistic wind movement in foliage.

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:

  1. Time: Multiply Time by a WindSpeed property to control the flow.
  2. Noise: Plug your time-offset UVs into a Simple Noise node to generate the wind pattern.
  3. Masking: Multiply the Noise output by the Vertex Color (specifically the Red channel) to ensure only the canopy moves.
  4. Displacement: Use an Add node to combine your original Position (Object Space) with the result of your noise calculation (multiplied by a WindStrength property).
  5. Output: Connect this to the Vertex Position slot 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.