The Goal: Growth Without Rigs
Animating growing vines usually needs skeletons (rigging) or complex caches. I wanted to do this entirely with Shader Math to keep it simple and fast.
The challenge: How to make a static mesh look like it is growing out of the ground?
1. The Method: Vertex Displacement
Unlike my previous shaders that changed colors (Fragment Shader), this one changes the 3D shape (Vertex Shader).
The Workflow:
- Mesh: A cylinder modeled in Blender.
- Growth: Using Alpha Test to cut the mesh.
- Shape: Using Normal direction to make it thicker.
- Fix: Pinching the top vertices to hide the hole.
2. Mesh & UVs
The shader relies on the UV layout.
- Geometry: A curved cylinder.
- UV Mapping: The Y-axis (V) goes from 0 (bottom) to 1 (top).
We use UV.y as a timeline. If UV.y is lower than the Growth slider, that part of the vine is shown.
3. Growth Logic (Opacity & Thickness)
A. The Cut (Alpha Test)
To show the vine growing, I use Alpha Test (Masked Mode).
- Logic: I subtract
UV.yfrom theGrowthvalue. - Result: If the result is negative, the pixel is deleted (clipped).
This reveals the vine from bottom to top, but it leaves a flat, open hole at the top.
B. Controlling Thickness (Dual Curves)
To make the vine look organic, I can’t just scale it evenly. I used two separate curves and combined them.
- Body Curve: Controls the main thickness of the vine. It keeps the grown parts thick.
- Tip Curve: Controls the very end of the growth. It makes the tip sharp.
- Max Node: I use a
Maxnode to blend them. It simply picks the larger value. This ensures the stem stays thick while the tip can still be sharp.
4. Closing the Hole (The Pinch)
Since Alpha Test cuts the mesh, the top is hollow. To fix this, I added a specific offset to the tip.
The Logic: I calculate the final position by adding two offsets together:
- Main Expansion: Pushes vertices out to make the vine thick.
- Tip Pinch: Pulls vertices in (negative offset) but only at the very top edge.
Why Additive? By adding a negative value (like -10) to the tip, the vertices are forced to collapse into a single point. This creates a cone shape that closes the hole.
5. Lighting (PBR)
For the surface, I used standard PBR textures (Albedo, Normal Map). Because I modified the vertices in the shader, the PBR lighting (shadows and highlights) updates automatically as the vine grows and changes shape.