Archived

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

AxeMan13

calculating terrian normals

Recommended Posts

Hi there! Does anyone know a fast way to calculate terrian normals? I want to page in patches of terrain on the fly from the raw height data. This would involve calculating the normals along with the vertex positions and texture coords. Surely there must be an approximation of the normals based on the relative heights of the neighbouring vertices rather doing many cross products. Thanks in advance!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you can find the formula in any calculus book in the chapter about partial derivatives and surfaces..

in case not, the idea is:

cross(h[x+1,y]-h[x-1,y], h[x,y+1]-h[y-1]);

you can simplify it a bit as you see when you write the whole thing out..

maybe this will get you a reverse normal, if so just negate it.

Share this post


Link to post
Share on other sites