Jump to content
  • Advertisement


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


Terrain Normal Problem

This topic is 5648 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

I have a textured terrain consisting of quads/tiles that can be modified at runtime (using picking) by raising or lowering the z-value of the vertices. The terrain is flat at the outset. So far I have modified the normals'' z-value by the same amount as that of the vertex but this only creates some sort a crude shadowing effect. The question is how to calculate smooth shading for the terrain (already works for models). I guess some sort of averaging of surrounding faces/vertices should be used but I have not found any practical to use. Anyways, thankful for any help!

Share this post

Link to post
Share on other sites
Thanks L_dot_N but I still can''t get it to work. Is it possible to get a more detailed description?

I tried to add all surrounding normals and then dividing them and then call D3DXVec3Normalize. Looks a little better but is still very wrong.

At the outset my terrain is flat and all vertices have normals x=0, y=0, z=-1. I never modify the x and y positions on the terrain itself but I have a feeling that the normals'' x and y should change?

Share this post

Link to post
Share on other sites
float h1=height[x+1][y];
float h3=height[x-1][y];
float h2=height[x][y+1];
float h4=height[x][y-1];

float nx = h3-h1;
float ny = 2;
float nz = h2-h4;
float l=sqrtf(nx*nx + ny*ny + nz*nz);
nx/=l; ny/=l; nz/=l;

of course in that case the terrain isnt standing upright and if youre stretching the landscape or heights you will have to use a factor for each height.

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!