Procedural Terrain Generation: How can I make different terrain types?
Hello!
I followed this amazing tutorial on youtube to procedurally generate terrain.
It's a long tutorial series but the concepts are pretty simple:
Get the height of the terrain from Perlin noise
Use the height of the terrain to determine what type of terrain it is (water -> sand -> grass -> rock etc.)
I don't like that I'm using the height to determine the terrain type. This is all handled in a surface shader which you can see here. Essentially (in this surface shader) we just use IN.worldPos.y
to determine what texture to output on the surface. So lower heights are assigned the water texture, then sand, then grass, rock etc.
This feels very restricting and makes the terrain uninteresting.
Is there a way for me to pass more information into the shader? Maybe I could add some extra information to each vertex and somehow access that in the shader (this could allow for different biomes). Or maybe I should try a different approach altogether.
Any advice would be much appreciated, thank you!
Answer by Snubber · May 15, 2020 at 03:19 PM
I realized I can use the Mesh's uv to pass information to the shader, So when I generate the Mesh I can also set the UV so it knows what texture to grab. Now I am no longer restricted by the height!
Your answer
![](https://koobas.hobune.stream/wayback/20220612234239im_/https://answers.unity.com/themes/thub/images/avi.jpg)