Mediums

What is a Medium

Rather than building every wind interaction from scratch, Zephyr's medium system allows you to quickly add physics behaviors of various types of materials (or mediums) to a shader. Need to add wind to your trees? Simply add the Tree Medium to your vertex offset. All mediums are designed to work in either HLSL or Shader Graph and can easily be adjusted to get the look that you need.

Mediums are pre-built combinations of vertex transformations that directly pull from Zephyr's wind direction and create motion. If you already have a shader that uses wind and want to keep that same motion, it is likely easier to update your existing wind shader than to try to apply a preset medium to your shader.

Made of Components

All mediums are made up of a number of components. These components separate out various aspects of the way that wind effects a material into easy to edit sections. For example, a Tree Medium might have 4 components: trunk bending, branch bending, branch bounce, and leaf flutter. Each of these components have controls for intensity, speed, and scale along with a mask value that multiplies the strength of the noise wave.

You can see how all of these parameters interact in 2D with this graph. In the graph, you can see the interaction between the mask, speed, scale, and intensity.

One thing to note is that both speed and scale impact the rate at which peaks appear so often these parameters need to be tweaked in accordance with each other. Also notice the multiplicative relationship between the intensity and the mask.

Edit the graph to play with every setting here: https://www.desmos.com/calculator/fplacs7jtl

Mask, Masks, and More Masks

When applying an effect to your mesh, you will likely want to not apply it uniformly to all parts of your mesh. The way to get around this, is to use masks when applying it to your shader. A mask is any value from 0 to 1 baked into your mesh that you can use as a multiplier for your wind effect. There are 3 different recommended masks, but you can bake data into your models in many ways!

Position Masks

The easiest way to mask wind is to use a position based mask. In this example, the object space of the vertex is calculated using a position node. The Y-coordinate is saturated and then used as a mask for a cloth medium. This example will apply more wind as vertices are higher.

CHALLENGE: How can this example be adjusted to support tall trees that have vertices taller than 1 unit above the ground? Using the unmodified data will cause tall trees to blow much further than shorter counterparts. Check out the demo tree shaders in the package to see an example of how to do this!

UV Masks

Another way to mask wind is to use a UV texture coordinate. This is positional data that is stored in your meshes vertex data that is most commonly used to tell the renderer where to place textures. You can use any of the 4 UV channels to hold data for wind.

Using UV Maps in Blender

Vertex Colors

The most common way to store wind data in meshes is with vertex colors. Vertex colors are 4 dimensional vectors that are stored for each vertex in your model. You can use any of the 4 channels (Red, Green, Blue, Alpha) to store wind data.

Vertex Colors in Blender

Pre-built Mediums

Tree

Apply tree-like physics to your shaders.

Plant

Apply physics of small vegetation (such as grass, ferns and bushes) to your shaders.

Cloth

Add to your shaders to apply cloth physics to your vertex offset.

Structure

Apply simple wind to your shaders. This is useful for swinging signs, rickety beams, and other materials that move as a single unit.

Have a Medium Suggestion?

Reach out to us via Discord! We are always looking to add new behaviors to extend the system further.

Last updated