Gamedev Hub

Splatmap Texturing

A Splatmap (or Weightmap) is a control texture that tells the terrain shader which texture to draw where. This is how games achieve smooth transitions between grass, sand, and rock without creating thousands of unique textures.

1. How it Works: The RGBA Channels

A standard Splatmap uses the four color channels of a texture as weights for four different detail textures:

In the shader, we sample all four detail textures and multiply them by their respective weight from the Splatmap.

2. Shader Implementation (HLSL)

// Sample the control texture
float4 weights = tex2D(_SplatMap, i.uv);

// Sample the detail textures
float4 grass = tex2D(_GrassTex, i.worldPos.xz * _Tiling);
float4 dirt  = tex2D(_DirtTex, i.worldPos.xz * _Tiling);
float4 rock  = tex2D(_RockTex, i.worldPos.xz * _Tiling);
float4 snow  = tex2D(_SnowTex, i.worldPos.xz * _Tiling);

// Blend them
float4 final = (grass * weights.r) + (dirt * weights.g) + 
               (rock * weights.b) + (snow * weights.a);

3. Advanced: Texture Arrays

The 4-texture limit of a single RGBA splatmap is a common bottleneck.

4. Procedural Splatmaps

You don’t have to paint splatmaps by hand. You can generate them based on the terrain’s geometry:

5. Summary