newb question about normals!

Started by
2 comments, last by Aargyle 21 years ago
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!
Advertisement
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
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]
our new version has many new and good features. sadly, the good ones are not new and the new ones are not good
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...

This topic is closed to new replies.

Advertisement