Jump to content
  • Advertisement

Archived

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

revearz

Calculating normals in height field

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 ).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!