Vertex and Face normals in Interleaved arrays.

Is it possible to use both vertex and face normals in interleaved arrays? If soo how do I tell GL the face normal?

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.

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.

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.

Thanks…=)

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.

What if you want something with a facetted appearance? Diamonds, for example. Not everything needs to be smooth.

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).