Calculation of normals for height map

I have a little problem calculating the normals for my DEM. This is a weird behavior. The normals are good at the top and bottom points, but in the middle they seem to be wrong. They are spotlighted.Problem

REMOTE SOURCE

EDIT: Tried 2 new approaches:

This is normal. It looks great, but you see individuals.

Position normal = crossP(vectorize(pOL, pUR), vectorize(pOR, pUL));

I also tried to do this per-vertex this way, but also with a weird way out.

enter image description here

This is a proposal made by Nico:

He also looks rather strange. Maybe there is a mistake in how I calculate the help points.

REMOTE SOURCE

enter image description here

EDIT 2: Defining my points: OL, OR, UL, UR - the angular vertices of the plane that should be drawn.

                postVertPosZ1 postVertPosZ2
preVertPosX1         pOL           pOR         postVertPosX1
preVertPosX2         pUL           pUR         postVertPosX2
                 preVertPosZ1  preVertPosZ2

EDIT3:

. : y .

. enter image description here

+4
1

. . . -, :

. :

  T
L O R
  B

O - , . (, , , ) . :

             /           2           \
horizontal = | height(R) - height(L) |
             \           0           /

             /           0           \
vertical   = | height(B) - height(T) |
             \           2           /

- :

normal = normalize(cross(vertical, horizontal))
                   / / height(L) - height(R) \ \
       = normalize | |           2           | |
                   \ \ height(T) - height(B) / /

, , x , z - .

+6

Source: https://habr.com/ru/post/1616054/


All Articles