Unity Snow Shader

 
Snow.gif

Rendering is an area that I love working on but I don’t get to work on it often. Recently I saw a beautiful game in which one of the environments was covered in snow. I started to think how they would have achieved the effect.

My first instinct was that it was particles but that would be very expensive and then I though maybe the models were made keeping in mind the snow. That would be one possibility and but that would be a change on the asset pipeline side.

I researched on this topic and found out that it was a shader. Since that on;y shader I had written was in DirectX I thought this will be a good way for me to try out Unity shaders. I looked up some documents online for Unity shaders, watched some tutorials for the snow shader and I was set. I experimented with some parameters and arrived at the above result. I really like how it turned out and I think my first try in Unity shader has been successful.

Concept behind the shader:
Vertex Shader
Using the dot product between the vertex 
normal and snow direction, determine if there 
should be snow on the vertex. If there should 
be, move the vertex in the direction of the 
normal.
Optional: When moving the vertex use a 
displacement map and to get a multiplier. I 
also used Tessellation for a better 
displacement result.
Pixel Shader
Sample from the Normal Map and dot product 
the sampled vector and the snow direction to 
determine if the pixel should have any snow 
on it. Use a blend method to blend the the 
two base color and the color of the snow.
Optional: If the surface is very flat , use a 
Perlin noise texture to add randomness. 

I will be taking up more projects like these, because I believe in “never stop learning”.

 
Previous
Previous

Hold Shift to Sprint

Next
Next

Set it and Don't Forget it