This page looks best with JavaScript enabled

Writing a Snow Covered Shader

 ·   ·  ☕ 1 min read

Lets write a custom snow covered surface shader in Unity that can procedurally generate snow and place it on top of any object in our scene. This will let us add any amount of snow to an object in any orientation and get it placed in your world really easily.

This shader is built using world space normals and dot products.

Every mesh has normal values applied to their vertices, these normals represent the orientation of the vertex in object space. object space is the orientation of normals relative to the object itself. We want these normals in world space so that they are relative to the rest of our game world.

Once we have the world space normal we can compare that to the direction of our snow. We use a dot product for this. Then, after we have a measure of how in-line our world space mesh normal is with the snow direction we can determine whether to draw snow or the default texture.

The snow covered shader is available on GitHub here:

Join the World of Zero Discord Server:

Sam Wronski
Sam Wronski
Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!