Unity Shader
Thick snow footprint shaders
Unity solution to use tessellation shader to generate footprint on thick snow ground.

Source code and demo files can be download from Github page.


Animation in Unity with Vertex shader

In modern video games, the interaction between the character and the environment helps to add the realistic feelings and give the player more emerging experience. Footprint is one feature to make the character feels more like to walk on ground rather than floating.In common cases, using decal textures on that surface is a simple solution. However in some special environment surfaces such as snow ground, sand ground and muddy surfaces, the ground mesh should also change shape to simulate the real world.

Using normal map and parallel map can “fake” the effect by changing the surface lighting result and displacing texture according to view direction. This method can achieve satisfactory result when the surface change is subtle. But when comes to the situation of thick snow or sand   surface which have big deformation when character step on, the better solution is to actually deform part of the surface mesh. The tessellation/domain shader in shader model 4 and up offers more easier way to subdivide part of the mesh and do the vertices displacement with GPU.

In this project, I am trying to give a solution to
1. Dynamic subdivide parts of the ground mesh in the locations where the player have been stepped on.
2. Displacement the vertices according the footprints’ locations and directions, and also recalculate the normal and tangent directions to avoid artifact light result.
3.Place the detailed decal normal textures with generated local UV coordinates.The footprints that generated before will gradually disappear during a period of time.

Problems & Challenges:

1.To record the footprints’ locations and directions. Using texture large enough to cover all the terrain and direct paint the displacement map is a solution, but the resolution on the local close-up scene is still relatively low.

2.Need to figure out a efficient way to recalculate the normal and tangent in the shader program.

3.To calculate the local UV coordinates’ for the detailed footprint’s occlusion and normal map.


1. Mind the data interpolation between different stages: for example, if the local detailed UV is pre-calculated in the vertex shader or domain shader stage, the interpolation process will get the lerp result at the edge of local UV patches, and that will lead to  artifactual result.To prevent the situation above, I implement a geometry shader to examine and discard the edge faces’ incorrect UV values.

2. The tessellation factors and method will lead to different tessellation results. It is better to try them out and pick the most suitable combination.

3. To maintain the normal and tangent continuous conditions, the function or height map are better to have C2 continuity or we can increase the delta value(increase the sample area) to get a blurred normal and tangent to avoid a sharp change.