PDA

View Full Version : how to use vertex arrays with multiple normals per vertex ?



speedy gonzalez
11-18-2003, 07:47 AM
My application keeps the vertex data as compressed as possible such that a given vertex might have more than one set of attributes (normals, colors, UVs).

For instance a corner of a cube will have 3 normals, one for each adjacent face, otherwise with one normal the shading will look awfull.

In general an object will have say 10% of the vertices having discontinuities of either the normal, the color or the UVs.

I would love to use vertex arrays but given the single-index nature of vertex arrays I doubt I could use them.

I was wondering if anyone out there found a way to still use vertex arrays even for those cases ?

I know one of the solution is to split the vertex in N vertices for those cases but this will be a nightmare of maintenance in my case.

Ostsol
11-18-2003, 08:04 AM
Multiple normals for vertices shared by multiple faces? Technically, yes, but you wouldn't be able to render both faces at once. There's no way for OpenGL to know which normal vector to use for which face; it is up to the programmer to tell OpenGL which normal vector to use.

At a glance, I don't really see how it would help you. Most faces in a mesh would share normal vectors with no problem, so having a few extra vertices with the same positions, but different normal vectors probably adds much less data on average than having a couple more normal vectors for each vertex, even those that don't need the extras. (I hope that made sense. . .)

dabeav
11-18-2003, 09:43 AM
I found the same problem a long time ago, and after much delibration, came to the conclution that the ONLY method to do so, is create multiple instances of the same vertex, each having a different set of attributes. Sorry, sucked for me too.

pkaler
11-18-2003, 10:09 AM
Jon Watte has a quick little article on this. http://www.mindcontrol.org/~hplus/graphics