Recreating snow with a shader

by: Kelvin Noordenbos

Snow is beautiful. The crunch of freshly fallen snow under your boots, the crumble when you walk through it, that one snowball you threw “a little too hard”. No matter what your favorite part of snow is, the white blanket covering your streets will always leave you impressed by the scene of beauty before you. Snow has appeared in many games and therefore snow shaders have been done before. We can use the existing knowledge about snow and snow shader and bring it to the next step.

Table of contents

  1. Requirements
  2. Tessellation
    1. Fixed Tessellation
    2. Distance Based Tessellation
    3. Edge Based Tessellation
    4. Phong Based Tessellation
    5. Comparing the methods
  3. Snow Deformation
    1. Depth camera
    2. Depth Texture
    3. Displacement
    4. Persistent Texture
    5. Perlin Noise
    6. Edge smoothing
      1. Implementing Phong tessellation
    7. Raising the edges
  4. The looks
    1. Snow
    2. Ground
    3. The edges
  5. Final Result
    1. Performance and Scale
    2. Improvements
      1. Remapping the normals
      2. Triplanar normal mapping
  6. Sources

1. Requirements

Black Myth: Wukong snow effect

My reference is Black Myth: Wukong. I want the final product to go deep into “how do you make snow look good”. The final product wont really account for performance and scalability but the techniques to improve those points will be written down in this blog.
The final product will be able to:

– Make objects of different sizes leave a good imprint in snow
– Make trails and imprints on different depth levels
– Make edges around the trails to account for moved snow.

We will also Go deeper into materials, displacement and normals of the snow.

2. Tessellation

To add depth to our plane, we need a form of tessellation. Tessellation turns the plane with a low vertex count into a surface with a large vertex count. This allows details like footsteps to be imprinted into the plane instead of having a large part of the plane pushed down due to the plain not containing enough vertices. First we are going to look at the logic behind the tessellation methods from unity. After

2.1 Fixed Tessellation

Fixed tessellation is a way of tessellation that applies the same amount of tessellation across a surface. Performance wise this is not the smartest move. The plane will have a high level of tessellation even if you are far away and no depth is applied.

Fixed Tesselation - Unity 2018
Fixed Tesselation – Unity 2018

2.2 Distance Based Tessellation

Distance based tessellation is a way of calculating tessellation based on the distance from the object tot the camera. This method makes sure that your computer does not tessellate stuff you cannot see. One large disadvantage is that if your camera is far away (for example an real time strategy game) the plane will lose a lot of detail when it should not.

Distance based Tesselation – unity 2018

2.3 Edge Based Tessellation

Edge based tessellation is an improvement over the existing Distance based tessellation. Edge based tessellation improves on it by computing the tessellation levels based on the triangle edge length on screen. This means that longer edges get a larger tessellation value.

To improve on performance you can use: UnityEdgeLengthBasedTessCull. This makes the shader more expansive but saves on the GPU by not rendering the stuff outside the camera’ s view.

Edge based Tesselation – unity 2018

2.4 Phong Based Tessellation

Phong tessellation is a bit different then the previous methods. The example of unity is based on the edge based tessellation example. Phong tessellation is used to make low poly meshes look more smooth by using the mesh normals. This makes surfaces look better without adding more tessellation.

Phong based Tesselation – unity 2018

2.5 Comparing the methods

To test which solution would benefit out project the most, four planes were created. To each plane we applied the a different tessellation shader. A light was also rotating around the planes to see the details in different lighting conditions. All Shaders were set to max tessellation to see the max level of detail they can create. This value will be tweaked in the end result.

As we can see in image on the top left, distance based tessellation drops out immediately. The plane does not retain a presentable level of detail when you move further away from the planes. In image on the top right we can see that fixed Tessellation also drops out due to having much more vertices then the other two. It is also not good practice to keep a high level of detail on parts that don’t need it. There was no visible difference between the Phong tessellation and Edge based tessellation. This is due to the normals not being set correctly when displacing the plane. For this reason Edge based tessellation was chosen. If the normals are correctly set in the future, the project will switch to Phong tessellation.

Related Posts