Terrain having multiple textures

Hi!

I’m developing a terrain procedural generator with Unity.

The terrain generator is already done, but i dont know how to continue applying different textures to the terrain.

I want to have the hill-like terrain with grass texture, the sharper mountains with rocks texture and water and rivers with, of course, water texture.

I only know the way to apply an unique texture to the whole terrain:

SplatPrototype[] tex = new SplatPrototype [TerrainTextures.Length];

for (int i=0; i < TerrainTextures.Length; i++)
{
    tex  *= new SplatPrototype ();*

tex .texture = TerrainTextures ; //Sets the texture
tex .tileSize = new Vector2 (1, 1); //Sets the size of the texture
}
tData.splatPrototypes = tex; // Apply texture
I can set many textures to the array in the Inspector, but this code only applyes the first.
Anyone can help with a sketch of code, please?
Thanks in advance.

You need to assign the control texture (AKA the splat map / alpha map), which you can do with the SetAlphamaps method. There’s an example at Procedural Terrain Splatmapping | Alastair Aitchison