Resolves slope stretching caused by the Triplanar shader, which automatically applies seamless textures to terrain and rocks without UV mapping.
Problem symptoms and specific phenomena
When using the **Triplanar** node in Shader Graph to project textures onto 3D models that are difficult to UV develop (such as vast terrain, cave walls, rugged rock surfaces, etc.), the following rendering artifacts occur in certain locations.
- The texture is displayed clearly on gentle slopes, but on steep cliffs or nearly vertical slopes, the texture appears unnaturally stretched vertically and horizontally (stretching phenomenon).
- The resolution of the texture is extremely low in the stretch area, and blurred linear patterns become noticeable.
- The texture suddenly switches at the boundary between polygons, making unnatural seams clearly visible.
An analogy for beginners: 3-way projector and diagonal wall
In order to understand the causes and countermeasures for this stretching phenomenon, let's compare Triplanar mapping to ``a situation in which three projectors are used to project a slide photo onto a complex-shaped rock sculpture in a dark room.''
The first projector projects the same texture pattern toward the sculpture from directly above (Y-axis) toward the floor, the second from the front (Z-axis), and the third from directly to the side (X-axis). If the surface of the engraving is facing directly above, the light from the projector directly above will hit it directly, allowing you to see a clear pattern without distortion. Similarly, if you have a vertical wall facing directly to the side, the light from the projector directly next to it will hit the wall vertically, giving you a clear view.
The problem is "a cliff slope facing at a 45 degree angle". Both the light from the projector directly above and the light from the projector directly to the side will hit this slope diagonally. If you shine a flashlight at a wall from an angle, the circle of light will be elongated and distorted into an oval shape. This is the true nature of the texture stretching bug.
The `Blend` parameter to solve this problem is ``a function that blurs the boundary line where the light from two projectors overlaps and blends them smoothly.'' Increasing the Blend value is equivalent to widening the blurring of the projector lens and applying a gradation that cancels out each other's distorted parts so that they overlap neatly. Additionally, by conveying the fine irregularities (normal information) on the surface of the sculpture, it becomes possible to automatically correct the angle at which the light hits.
Assumed main causes
The stretching phenomenon in the Triplanar node is caused by the following two missing settings.
- Blend too low: The Triplanar node's `Blend` parameter determines how much the transitions of the projection axes (X, Y, Z) overlap and blend. With the default value of `1.0`, the blend boundary is too sharp, so parts with severely distorted projection angles will be exposed on the screen.
- Normal input not connected: If a node's `Normal` input is left empty, the shader uses only simplified vertex normal information to calculate projection weights, rather than each pixel's exact normal (slope). As a result, blending is not performed properly in the fine irregularities of the mesh, and the stretching becomes noticeable.
Specific solutions and procedures
Modify the settings and connections of the **Triplanar node** in the Shader Graph as follows.
Step 1: Increase Blend value (most important)
Select the Triplanar node and increase the value of **`Blend`** in the parameter inspector from the default `1.0` to something between **`5.0` and `8.0`**. The higher the value, the more the three projected textures will overlap with a smooth gradation, and the stretched intermediate areas will be hidden by the blend, making the texture appear more uniform to the human eye.
Step 2: Connect normal vector to Normal (Input)
Place a new **`Normal Vector`** node in the shader graph and set its spatial setting to **`World`** (World Space). Connect the output of this node to the **`Normal (Input)`** port of the Triplanar node. This allows the exact polygon slope at the pixel level to be reflected in the calculations and compensates for the three-sided sampling blend boundary very accurately.
Step 3: Optimize tiling and scaling
Adjust the density of the texture by entering the appropriate value in the `Tile` input of the Triplanar node. Also, make sure that the `Transform` scale of the connected 3D model is applied correctly, and project based on world space rather than object space.
Texture stretch prevention checklist for practical use
| Confirmation items | Ideal settings | Effects and benefits |
|---|---|---|
| Blend parameters | Adjusted between 5.0 and 8.0 | Smoothly hide the texture stretch of the slope with blending. |
| Normal input port | `Normal Vector (World Space)` is connected | Performs accurate three-sided sampling that takes pixel tilt into account. |
Below is a code block written as a custom HLSL to mathematically represent the calculation of blend weights in Triplanar mapping and to optimize shader graph calculations.
// Custom function to calculate 3-axis projection blend weights for Triplanar mapping
void CalculateTriplanarWeights_float(
float3 worldNormal, // World space normal vector (input)
float blendPower, // The sharpness of the blend. 5.0 to 8.0 recommended (input)
out float3 blendWeights // 3-axis blend ratio (output)
)
{
float3 absNormal = abs(worldNormal);
float3 weights = pow(absNormal, blendPower);
blendWeights = weights / (weights.x + weights.y + weights.z);
}
By mastering this Triplanar node's blend settings and normal connections, artists can quickly apply beautiful materials to terrain and obstacle assets that are seamless and distortion-free from any angle, while saving countless hours of manual UV unrolling for each mesh. This is a highly effective procedural method for improving the quality of background graphics.