Tri-planar Materials with Terrain shader

This page a brief covering the proper setup and basic usage of Triplanar Terrain Detail Materials

NOTE: The screenshots are from an older version of Lumberyard and I haven’t updated em yet, but the procedure should still be similar.

What is Triplanar?

Triplanar mapping is a technique for mapping and blending multiple textures in world space. The advantage of this is that you can use the shader on a terrain, for example, and the textures would map without stretching, even on steep cliffs.

What does this mean in Lumberyard?

Lumberyard is not exactly true Triplanar mapping in the traditional sense… in Lumberyard, you create Terrain Layer that uses a Multi-Material , that has 3 sub-materials (Terrain.Layer Shader) which are mapped to the terrain mesh with an X, Y and Z projection.

Instead of computing the blended projections within the shader, it internally treats each submaterial as a sub-layer (with a draw call) bound to each projection.

In Lumberyard, this approach is more similar to Triplanar Splatting.

Basic Workflow Steps

The Following steps are assumed:

  1. You’ve created a new level (recommend experimenting with a smaller size and 4k terrain texture)
  2. You’ve sculpted some terrain (with lots of vertical cliffs)
Starting point

My level looks like this … with the default Terrain Layer applied

Close up of stretching on cliffs

Basic Triplanar Material (for testing)

  1. Open the Material Editor

  2. Right-Click on the \Materials\ Terrain folder
    a. Select the option ‘Add New Multi-Material’ and save it into the materials folder:

    i. \materials\terrain\triplanar.mtl

  3. Set up each of the 3 sub-materials:
    a. Change the names of sub-materials to: X, Y and Z
    b. For this example, change the color of Diffuse Color (Tint) … I used Red, Green, Blue respectively
    c. And for the diffuse texture, I used: engineassets/texturemsg/defaultnouvs.tif
    d. Make sure each sub-materials Shader is: Terrain.Layer

Here is what that looks like:

Create Terrain Texture Layer and Assign Material

  1. Open Terrain Texture Layers Editor
  2. Click Add Layer
  3. Double-click on layer and rename to ’ Triplanar
  4. Make sure this Triplanar layer is selected
  5. Click Assign Material
    a. This will open the Material Editor
    b. Browse to Triplanar Multi-Material we previously created (\Materials\Terrain\triplanar.mtl) and make sure this material is selected
  6. Head back to the Terrain Texture Layers Editor, and click again on Assign Material
  7. Click on Change Layer Texture
    a. Browse and switch this image to white: Engine\EngineAssets\Textures\white.tif

That should all look like this for reference:

Paint with Layer Painter

Now you can go into the Lumberyard Layer Painter and paint the Terrain Layer onto the Terrain Mesh

  1. Configure your brush
    a. Color Opacity: 1.0
    b. Detail Intensity: 1.0
    c. Brightness: 0.5
    d. Color: White
  2. At the bottom, you will see a List of Layers
    a. Select: Triplanar
  3. Press Flood (button)
    a. This will flood fill the terrain with the Triplanar layer

What this looks like:

As you can see, the three sub-materials were projected to the terrain based on the orientation of the Terrain Mesh Normals

The white areas, are where the terrain sectors are blending to the terrain layer beneath (which in this case, is the default layer). This is where I say this isn’t traditional triplanar mapping (which has 3-plane blending), this is actually more of a system to splat into three different (axis aligned) projections. And this is also where the flaws are, because splat weighting reduces down to the blend between two layers, you will always have seams and areas that are mapped in a distorted/stretched UV space.

The pros are, in the areas splatted with these projections there is far less distortion (more square, better aligned, less stretched diamond UV’s)


Example using Megascan Studio, a material with texture inputs for soil map that uses the Terrain.Layer Shader

4 Likes