An interactive landscape material/shader for Unreal Engine 4.
The shader was initially developed during the prototype phase for the game Til Nord. They needed a shader where the vehicle and other objects interact with the snow on the terrain. During development the shader got build into an generic landscape shader that could be used for all kinds of terrain types. This resulted in project Arid using it as well.
- Displacement interaction (with optional layers)
- Displacement recovery (snow like)
- Height based layer blending
- Distance based tessellation
- Distance based UV tiling
- Up-to 8 Layers (2 x 4)
- Per layer features (using shader keywords to optimize the performance)
- Terrain holes
The first prototype was made in Unity (no final decision on engines made yet by the other projects), I used this time to explore compute shaders and used them to update the mask textures generated by a depth capture camera (but using Graphics.Blit might have been a better solution). This version can be found on GitHub, but is far from optimal.
The final version was made in UE4 and is made in the material editor. To optimize the shader, features can be enabled using keywords, leaving out unused calculations when compiling the shader. The shader has 2×4 layers, what I still would like to improve (but couldn’t find in the material editor) is something like an ‘add pass’, or at least that is what it is called in Unity. This will add a new pass to the shader when needed, so you could add 4 textures at a time until the limit it reached. You also only have to create the code once.