#### Archived

This topic is now archived and is closed to further replies.

# Calculating normals in height field

This topic is 5548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I have a height-field with non-uniform spacing. I want to compute the normals of the height-field. I used finite differences but want something more accurate. My height y = Sum from 1..n ( a * cos( b ) ) so I think I could differentiate this formula to get find the normals. y = Sum from 1..n ( a * cos ( b ) ) where a,b are constants y'' = Sum from 1..n ( -a * sin ( b ) ) What would the normal be? ( dy/dx, ..., dy/dz )? dy/dx = ( Sum from 1..n ( -a * sin ( b ) ) ) / dx dy/dz = ( Sum from 1..n ( -a * sin ( b ) ) ) / dz What should dx and dz be equal to since my height-field has non-uniform spacing? Thanks in advance!

##### Share on other sites
why don''t you just use the outer vector product?

##### Share on other sites
can t you get the normal of each triangle of a terrain tile (QUAD==2 triangles in this case)

and then average the normals of neightbouring tiles?

(n1+n2+n3+n4)/4

##### Share on other sites
quote:
Original post by Basiror
can t you get the normal of each triangle of a terrain tile (QUAD==2 triangles in this case)

and then average the normals of neightbouring tiles?

(n1+n2+n3+n4)/4

where the normals are wighted with the triangles area...

(|N1|*n1+|N2|*n2+|N3|*n3+|N4|*n4)/(|N1|+|N2|+|N3|+|N4|)
where N{1, 2, 3, 4} are the non-normalized normals ( Area = |(oneside x anotherside)| )

##### Share on other sites
The methods proposed means that I need to know my neighbouring vertices. Since I''m calculating my vertex position in a vertex shader, I have to do 4x the work ( need to calculate neighbour''s vertex position too ).

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633735
• Total Posts
3013593
×