Calculating normals in height field

Started by
3 comments, last by revearz 20 years, 6 months ago
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!
Advertisement
why don''t you just use the outer vector product?

our new version has many new and good features. sadly, the good ones are not new and the new ones are not good
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
http://www.8ung.at/basiror/theironcross.html
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)| )

our new version has many new and good features. sadly, the good ones are not new and the new ones are not good
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 ).

This topic is closed to new replies.

Advertisement