For every terrain texture store an additional blend amount in your terrain vertex. This blend amount is simply a float
value in the range of 0
to 1
, where 0
means zero opacity and 1
means that the texture is fully opaque.
In the pixel shader you can use this amount to interpolate between the sampled pixels from the base texture and the blended one.
In this picture you can see a 3*3 terrain with a ground texture and a grass texture on top of it. The numbers represent the blend amount for each of the vertices: