PDA

View Full Version : Vertex and Face normals in Interleaved arrays.



TJ
03-18-2002, 12:22 AM
Is it possible to use both vertex and face normals in interleaved arrays? If soo how do I tell GL the face normal?

zeckensack
03-18-2002, 02:14 AM
Normals are per-vertex. You can't tell OpenGL about face normals. A simple hack would be to specify the same normal for all three vertices in a triangle but you would then lose smooth lighting and the ability to use strips which will be a big loss performance-wise.

The 'face normal' OpenGL uses for culling is calculated behind the scenes with a cross product out of the distances between transformed vertices. And it's not a true normal anyway, more some sort of approximation which is sufficient only for that special case. You don't have access to that.

Bob
03-18-2002, 02:26 AM
Per-face normals can be used in OpenGL with glShadeModel(GL_FLAT). Then OpenGL will treat the first normal for each primitive as a face normal (not the same normal for each vertex, but true face normals). With face normals, the calculation are performed once per face, and the result is copied to all other vertices in the face. When using smooth shading with the same normal for each vertex, the calculations are performed once per vertex.

And OpenGL doesn't use any kind of face normal for back face culling. It calculates the signed area of the triangle in window space coordinates. Negative area means a backface.

vincoof
03-18-2002, 02:29 AM
using glShadeModel(GL_FLAT) will work but won't give very good results if you look close enough at the object. Moreover, it will still send 3 normals per triangle, and only the last normal will be used, ie 2 normals are sent even though they're useless -- it's a performnce hit.

TJ
03-18-2002, 02:44 AM
Thanks....=)

MikeC
03-18-2002, 11:01 AM
Originally posted by vincoof:
Moreover, it will still send 3 normals per triangle, and only the last normal will be used, ie 2 normals are sent even though they're useless -- it's a performnce hit.

Not in the case of triangle strips or fans. Though in general I'd agree - in this day and age I can't imagine many scenarios where rendering with face normals is worth the hassle.

Korval
03-18-2002, 11:24 AM
What if you want something with a facetted appearance? Diamonds, for example. Not everything needs to be smooth.

zeckensack
03-18-2002, 12:21 PM
Originally posted by Korval:
What if you want something with a facetted appearance? Diamonds, for example. Not everything needs to be smooth.

This is just like the classic cube example. Don't reuse vertices in these cases. It'll break lighting and if that weren't enough already, ATI will hate you for it (because of Truform).
http://www.opengl.org/discussion_boards/ubb/wink.gif