#### Archived

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

# Calculating vertex normals for a terrain

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

## Recommended Posts

Hey, I''ve been trying to calculate vertex-normals to a triangle-strip terrain. I''ve been trying to add this feature to GameTutorial''s terrain tutorial #2. Though, I didn''t manage to add this feature. I know how to calculate vertex normals for a model which uses regular triangles, but I have no idea how to do the same thing for triangle-strips. I''ve searched the net for a tutorial or a source code which does that, but found none. I''m using OpenGL to render, but I presume it doesn''t really matters in this case. Please, can you tell me what''s the algorithm to do it? Or, can you please link me to some tutorial/source code? Thanks, Yuval

##### Share on other sites
There are 2 solutions:
1) you calculate your normals before generating the triangle strips (if possible). You anyway will have to add them to the mesh (I guess).

2) when calculating from the strips, what exactly is your problem? You know what a strip is, so you know how to get the 3 vertices for your normal calculation. Go over your strip array, and get a vertex (starting with the third); the previous two vertices right before it are the other 2 edges of the triangle.

- thomas

##### Share on other sites
i''ve found that what works the best is to take each vertex and calculate the normal vector for each of the six triangles which contain it. average those normal vectors to get the normal that you will set when drawing the triangle strips. you end up with slight lighting inaccuracies on sharp peaks and valleys but if your terrain is largely rounded it looks good.

if you want better lighting, you should construct a lightmap for your terrain. that way you can construct the lightmap using a seperate normal for every single triangle on the mesh which will end up looking much better.

-me

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633295
• Total Posts
3011245
• ### Who's Online (See full list)

There are no registered users currently online

×