2D Wind Vertex Shader
The Goal
To breathe life into 2D environments (foliage, cloth) without relying on expensive CPU-based physical simulations or heavy skeletal animations. The solution needed to be fully processed on the GPU.
How It Works
Instead of animating the sprite, I built a Shader Graph that manipulates the object's vertices in real-time to simulate organic, rolling wind patterns.
- Procedural Noise: Driven by a Gradient Noise node combined with Time and Speed parameters to generate the waving force.
- UV Masking (The Anchor): The core challenge was keeping the bottom of the plants attached to the ground. I split the UV coordinates and used the vertical gradient as a mathematical mask.
- Vertex Displacement: By multiplying the noise output by the UV mask, the displacement force drops to zero at the root, while the top receives the full sway. This data is injected into the X-axis of the Vertex Position.
- GPU Performance: Moves all wind calculations entirely to the GPU, ensuring zero overhead on the CPU logic thread.