- Home /
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 [i] = new SplatPrototype ();
tex [i].texture = TerrainTextures [i]; //Sets the texture
tex [i].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.
Answer by tanoshimi · Nov 07, 2014 at 09:12 PM
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 http://alastaira.wordpress.com/2013/11/14/procedural-terrain-splatmapping/
Your answer
![](https://koobas.hobune.stream/wayback/20220613170956im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Terrain in an RTS style game 1 Answer
Convert terrain with trees to image 0 Answers
Load Terrain Alpha Maps and Edit them 0 Answers
TriPlanar Textures Not Working Properly 1 Answer
Terrain texture getting black tinted 0 Answers