Simple Shaders

For simple shaders, we can grab Zephyr's value directly and use it to add wind offset. While the behavior is not as realistic as it could be, it can provide a good head start when creating your own wind interactions. For more detailed physics out of the box, try using one of the pre-built mediums!

Shader Graph

1

Create a New Shader Graph

To start, create a new shader graph at Create/Shader Graph/URP/Lit Shader Graph

2

Create the Zephyr Wind Node

After opening your new shader graph, right click on the blackboard to add a new node. Navigate to Distant Lands/Zephyr/Zephyr Wind and add it to your canvas.

3

Add the Position to the Node

Create a new position node and pass the value of that node into the Zephyr Wind node

Make sure that the space is set to World in order to properly pass the position of the vertex into Zephyr.

4

Use the Function Outputs to Simulate Wind

Each of the outputs of the Zephyr node give you access to a unique component of the combined wind. The Wind output gives you the combined wind. This only gives the offset so it must be added back to the local vertex position before being passed into the vertex offset in Shader Graph.

Learn more about vertex displacement in Shader Graph here:

Vertex Displacement in Shader Graph

Amplify Shader Editor

1

Create a New Amplify Shader

To start, create a new Amplify shader at Create/Shader/Amplify Surface Shader. Be sure to set the pipeline target to URP.

2

Create the Zephyr Node

Right click on your blackboard and navigate to Zephyr/Zephyr Wind to add the node to your canvas.

3

Use the Function Outputs to Simulate Wind

Each of the outputs of the Zephyr node give you access to a unique component of the combined wind. The Wind output gives you the combined wind. This only gives the offset so it must be added back to the local vertex position before being passed into the vertex offset in Amplify unless your vertex offset is set to relative.

HLSL

1

Open the Shader File

Find the shader you want to add wind to. This might be a .shader, .hlsl, or .cginc file. You can usually identify it by the name of the material you’re using — right-click it and select “Edit Shader” in Unity.

2

Find the “Vertex” Section

Search (Ctrl+F) for one of these words inside the shader file:

vert
vertex
appdata
v.vertex

You’re looking for a function that looks something like this:

void vert(inout appdata_full v)
{
    // This is where the vertex is modified
}

or maybe this:

v.vertex.xyz += someMathHere;

That’s the part that moves the mesh’s vertices. We’ll inject Zephyr’s wind into that section.

3

Include Zephyr’s Wind Code

Right above your vertex function (or near the other includes), paste this line:

#include "Packages/com.distantlands.zephyr/Runtime/Shaders/HLSL/ZephyrWind.hlsl"

This line brings in all the Zephyr wind functions and settings — you don’t need to define them yourself.

4

Get the Vertex’s World Position

Inside the vertex function, find where the shader gets each vertex’s position. Usually, it’s something like v.vertex or input.position.

Add this line below it:

float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;

That line converts the vertex position from object space (relative to the mesh) into world space (relative to the scene). Zephyr’s wind works in world space, so this step is essential.

5

Ask Zephyr for Wind at That Position

Now add this line underneath:

float3 wind = GetWindAtPoint(worldPos);

This tells Zephyr to return a 3D wind vector based on where that vertex is located in the scene.

That wind includes:

  • Base wind (the constant breeze),

  • Gusts (large shifting waves of wind),

  • Flutter (small, fast vibration),

  • Any local Wind Zones nearby.

6

Apply the Wind to the Vertex

Now make the vertex move according to the wind:

v.vertex.xyz += TransformWorldToObjectDir(wind) * _WindStrength;

That line:

  • Converts the world-space wind back into object space (so your mesh doesn’t deform oddly),

  • Scales the strength of the effect with _WindStrength (you can add this property to your shader or hardcode a small number like 0.2).

So the full section now looks like this:

#include "Packages/com.distantlands.zephyr/Runtime/Shaders/HLSL/ZephyrWind.hlsl"

void vert(inout appdata_full v)
{
    float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
    float3 wind = GetWindAtPoint(worldPos);
    v.vertex.xyz += TransformWorldToObjectDir(wind) * 0.2;
}

And that’s enough to get working wind movement. Feel free to manipulate the wind output at this stage to better fit your material's needs!

Last updated