# OpenGL surface normals and Vertex Normals

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

## Recommended Posts

I have two questions regarding this topic.

1. whether OpenGL API glNormal3f computes Vertex Normal or Face Normal?
2. Face Normal or Vertex normal, which one is used for lighting calculations?

I am lot confused between these two types of normals.

Until today, I thought there is only one normal calculation. It is computed by taking cross product of two edges of a triangle. Suppose V1,V2 and V3 are the vertices of triangle, then Normal is the cross product between vector (V2-V1) and (V3-V2).

Can we call this cross product of edges as vertex Normals? If so, then how do you compute face normal.

##### Share on other sites
Nah the cross product is actually the face normal.
vertex normals are when you average the connecting faces into a single vertex normal.

Clear? :)

##### Share on other sites
glNormal3f doesn't compute anything. It just sets the current normal value that's used for light calculations.
"Face normal", as RouncED mentioned, can be calculated as the cross product of 2 edge "vectors". It is usually used for physics or the logic, not by the renderer (especially on modern GPU:s).
"Vertex normals" are normals specified by vertex (for every vertex). They are usually used by the renderer. They can be calculated/determined in may ways, a lot of modelling programs/tools can export vertex normals, so you don't have to calculate them yourself in the program. Usually vertex normals are calculated by averaging the face normals of the neighbouring polygons (as RouncED mentioned), taking "Smoothing Groups" into account.

To be honest, I suggest you to google the terms. I'm pretty sure you can find a lot of info about them.

##### Share on other sites
So Surface Normals and Vector Normals are computed in the following way.

// face Normal Computation// Given edges(vector a and vector b) of a triangle // we take its cross product to find the  face normal.vector* FaceNormal(vector* a, vector *b){     vector *FaceNormal = cross(a,b);     FaceNormal = Normalize(FaceNormal);     return FaceNormal;   }// Vertex Normal computation.// Suppose V1,V2,V3,V4 are vertices and V1,V2,V3 form a triangle// and V1,V3,V4 form its adjacent triangle,then Using FaceNormal function // we compute FaceNormal1(with edges V2V1 and V3V2) and // FaceNormal2 (with edges V1V3 and V3V4) and then // we compute the vertexNormal at V3, by averaging the  FaceNormal1 and// FaceNormal2.  vector VertexNormal(vector *FaceNormal1, vector *FaceNormal2){     Vector VertexNormal = (FaceNormal1 + FaceNormal2)/2;     VertexNormal = Normalize(VertexNormal);     return VertexNormal}

Which Normal should we use for lighting calculations (i.e we specify in the function glNormal3f).

##### Share on other sites
Yeh thats right, except that when averaging normals, you can either divide by the amount (which is 2 in your example) or you can simply normalize, you dont have to do both.

Its the vertex normals that are used in lighting calculation, but with the geometry shader, you can compute face normals on the fly and flat shade.

##### Share on other sites
Um... you can't just calculate vertex normals like that.
You have to sum all the face normals of all the neighbour polygons, and you should weigh them too. After that, you have to normalize the result.
And take smoothing groups into account, or split the mesh according to the smoothing groups (you have to split the mesh if you use VBO-s).

weighing: there are different methods: you can weigh by the area of the polygons, you can weigh by the angle between the two edges that go into the vertex, etc

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 11
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632923
• Total Posts
3009229
• ### Who's Online (See full list)

There are no registered users currently online

×