0

So I'm working on procedural generation in unity and I've got to a point where I'm working on blending between two chunks of terrain (Each chunk is a square for reference).

To do this with the height I generated a 3 dimensional array which is of a size:

[numOfXVerts, numOfYVerts, numOfTerrains]

This is done so that [x,y, 0] stores the weighting of the forest terrain and [x,y,1] stores the weighting of the mountainous terrain and so on. This works with height fine as I don't need to use a shader however when using shaders I realised that I can't use a 3 dimensional array inside a shader.

So my question is two part, is there any conventional way for me to use weight the way that I have made it in a shader? and how is blending from one type of terrain to another usually done in procedural generation?

Reece Hewitson
  • 101
  • 1
  • 9
  • 1
    Generate vertices for the terrain and send the weights per-vertex as vertex attributes. The second question is much too broad and off topic for SO. – user2407038 Feb 28 '21 at 23:21
  • @user2407038 how do i add additional vertex attributes? I've looked into changing the Input struct but i believe there are only a few things which can be put in there as far as i'm aware? – Reece Hewitson Mar 02 '21 at 12:44
  • Your weights seemingly just floats so you can definitely make those into vertex attributes. Indeed, vertex attributes are limited in size but unless you have 100s of terrain types you should be fine. (If you do have a very large number of terrain types, then on the CPU, sort the weights for each vertex, and only send the highest `k` weights, ignoring the contribution of the rest of the layers). Unfortunately I don't know unity so cannot tell you how to add vertex attributes in unity. – user2407038 Mar 02 '21 at 21:43

0 Answers0