K
K
Ksenia2018-06-30 06:37:37
JavaScript
Ksenia, 2018-06-30 06:37:37

How do you work with heightmap resolution (2^k+1) (unity)?

Hey!
Tell me, when you need to correct the terrain heightmap from the code, and you need to split it into a certain number of equal parts, how do you divide it? If, for example, the resolution is 513, and the step by which the area should be divided is 8?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Daniil Basmanov, 2018-06-30
@Ksushqa

You need to split with duplication of vertices inside the seam. Let's take a primitive case with a four by four cell terrain, the size of the vertex array in this case will be five by five. Let's break it into four parts, each side will be divided in half. To calculate the size of the required arrays, you need to subtract one from the side, divide by two and add one. Thus, we get four three-by-three arrays, each containing two by two cells.
For your case, similarly, subtract one from 513, divide by eight, you get 64, add one, you get 65. That's the size of the array you need. At the junction, the vertices will be duplicated, but each piece will be independent.

G
Griboks, 2018-06-30
@Griboks

It is impossible to give a correct answer until you explain why 1 more, why zones and how their size is chosen. Resolution 513, I understand as byte[513,513].

K
Ksenia, 2018-06-30
@Ksushqa

It is impossible to give a correct answer until you explain why 1 more, why zones and how their size is chosen.

The documentation says quite transparently where the +1 comes from:
Heightmap Resolution Terrain's heightmap resolution in pixels (should be a power of two plus one, for example, 513 = 512 + 1).

J
Johnny Smith, 2018-06-30
@Olek1

https://habr.com/post/269645/
5b372e2b44d8f032686993.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question