I have this system to procedurally generate random terrain in unity using the built-in Terrain tool and I want to also procedurally generate the grass for this terrain only where the height of the terrain is above a certain threshold (where there is no water/sand) how should I do it?
There is here the solution on how to do it:
To explain it to you:
You will need to get the resolution of your terrain, find each pixels of it by using matrixes. For each pixel, you get the height of your terrain, look if it’s above or below the height you want, and then apply your grass.
Depending, you can also set a raycast for each pixel to get the normal of the hit point below each pixels of the terrain: depending of an angle threshold, you can also calculate how tilted is the surface and if you want to add grass at this place. (It helps with realism when you don’t want grass sitting on perpendicular surfaces)
Hope it helps!