#### Archived

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

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

## Recommended Posts

Ok when using gl lighting, you need to specify normals. I was wondering, is there one normal per vertex, one normal per triangle, or one normal per vertex per triangle? I would think that the normal would be the same at each vertex of a triangle, since the triangle is flat (one normal per triangle then, passed 3 times). But I''ve seen an awful lot of code that specifies normals per vertex. Whats the deal? Thanks!

##### Share on other sites
In OpenGL, each vertex has a corresponding normal.

If you want the triangles to be flat-shaded and have defined edges then you only need to supply one normal - this is then used to render each of the 3 vertices. You can get the normal for a triangle by taking the cross product of 2 vectors that lie on the same plane as the triangle.

If you want a smooth-shaded look to your model/terrain/whatever then you need to take the average of the normals for all the triangles that meet at that vertex.

Hope this helps

##### Share on other sites
if you have only one normal per triangle, lighting a object with a light source infinite far away, the lighting calculations will give the same results for each of the polygons' vertices. colour-interpolation is not required in that case.

one normal per triangle

if you use one normal per vertex, the resulting colour will be different for each vertex, and interpolated to look *nicer*.

one normal each vertex

in opengl each vertex has its own normal, unless you use the "flat"-shading option. then the normal passed to the first vertex of a triangle will be used for all of the triangle's vertices

[edited by - 666_1337 on May 1, 2003 5:48:18 AM]

##### Share on other sites
Yes they told you everything...

In geometry, a plane (or a polygon) has one and only one normal.

In OpenGL you can use this normal by specifying the same normal for every vertex (that is the same by specyfing it one time).
In this case you have flat-shaded poly...if you specify different normal for each vertex you can smooth spheres or cylinders as 666_1337 shown! Note that you can render a smoothed cylinders with only 6-8 edges and create the illusion of a real cyl!
These normals can be used in different ways: one methos is to compute the color for each vertex using its own normal and then do a color interpolation to fill the poly (gourad shading?).
Another method is to interpolate the normals on the texels (phong shading?).
And independently you can apply different lightning models.

In bump mapping (or similar algorithms) you can specify different normals for each pixel...

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

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

• Total Topics
631766
• Total Posts
3002228
×