# OpenGL Problem of triangle mesh normal caculating.

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

## Recommended Posts

Hi, all: I have wrote a program, which will parse *.3ds file, and display 3d object using opengl. I save 3ds object in triangle mesh, according 3ds format. My algorithm of caculating normal vector is : 1. Calculating every triangle surface normal. 2. Averaging triangle normals to compute vertex normals Ok, diplay some box object like blow. You can see obviously black line at top of box.
"Averaging normal not work very well." Now what can I do?

##### Share on other sites

Are you normalizing the normals? You should normalize the normals of each triangle before averaging and also normalize the normals of each vertex.

##### Share on other sites
Quote:
 Original post by xissburgAre you normalizing the normals? You should normalize the normals of each triangle before averaging and also normalize the normals of each vertex.

Actually it's often considered better not to normalize your face normals before averaging. That way faces with a larger surface area contribute more to a vertex's normal. It also has the added bonus of simplifying your code:
Set all vertex normals to (0,0,0)For each face (a, b, c){   face_normal = Cross(b-a, c-a)   vertex[a].normal += face_normal   vertex.normal += face_normal   vertex[c].normal += face_normal}For each vertex v   v.normal = Normalize(v.normal)

Here's another explanation, because I tend to suck at explaining things

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633660
• Total Posts
3013221
×