Sending Face normals with arrays

I’m running volumetric shadowing by extruding the object itself in the shaders depending on the faces’ normals. But my problem is that i’ve stored the vertices normals in arrays and i send them with arrays opengl functions but i can’t send the faces normals without creating a new buffer of 3*nb_faces. I want to know if there is an extension that could send an faces normals array directly with a buffer with a normal by face or if there is an other solution to this problem. (because it can be easily implemented in the opengl driver, i think it must exist).
Thanks for using your time understanding my bad english. :smiley:

Why would you want to send both the normals per vertex and a normal per face?
If you set the normals per vertex, the normal across the face is a linear interpolation of its three vertices.
If you set a normal per face, the normal is constant throughout the entire face. By respecting the counterclockwise order of the vertices, you can let opengl generate the normals for each face automatically.

Nico

Originally posted by -NiCo-:
Why would you want to send both the normals per vertex and a normal per face?
Because it would save having to calculate the face normals, which would reduce the number of GPU operations required.

[b]
If you set the normals per vertex, the normal across the face is a linear interpolation of its three vertices.
If you set a normal per face, the normal is constant throughout the entire face. By respecting the counterclockwise order of the vertices, you can let opengl generate the normals for each face automatically.

Nico[/b]
How do you get OpenGL to calculate your normals for you? I haven’t come across this extension.

I think the glShadeModel(GL_FLAT) computes the face normal with the vertices’ones, but there are two problems :

  • Perhaps it is not computed and the face normal used is one of the three sent.
  • “compute”, i would prefer save gpu access and because in theory the driver could send the faces normals without any time cost. I need only faces’normals for this pass, but creating another buffer will force me to make some minor changes into my architecture but it will cost a lot of memory and some basics cpu access for copying everything in this buffer :stuck_out_tongue:

I believe ShadeModel(FLAT) uses the first vertex normal for each primitive. GL does not calculate normals; glu can do it for the quadrics.

To have face normals, you have to split your geometry at each vertex, i e you have to use a different vertex array for your shadow object than you do for your rendering object.

Sure you can let GL generate them automatically by using the lowest order of evaluators and enabling GL_AUTO_NORMAL.
But I don’t think this really is the solution to your problem.

Nico

glShadeModel(GL_FLAT) calculates the color with the attributes of the first vertex in GL_POLYGON, all other primitives take the attributes of the last vertex of each subprimitive (point (obviously), line, triangle, quad).