• Advertisement

Archived

This topic is now archived and is closed to further replies.

vertex arrays and multiple normals per vertex?

This topic is 5714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Any ideas on how it''s possible to use vertex arrays for glDrawElements while having multiple normals for one vertex? For example, a cube contains only 8 vertices, but each shared by 3 faces. Each vertex should have its own normal for the faces to be lit correctly. But as I understand it, for vertex arrays to work you can only have one normal per vertex, since the array element indices must match up between the vertex array and the normal array. I see that you could simply add duplicate vertices to the vertices array for each vertex that required its own normal (only true part of the time, if you are averaging normals), but this seems like a waste of memory and GPU processing. Any suggestions on maintaining a minimal data set while using vertex arrays and allowing for multiple normals per vertex? Or am I barking up the wrong tree? Is there a better approach than using vertex arrays? I could use immediate mode obviously, but don''t want to lose the efficiency. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
quote:
I see that you could simply add duplicate vertices to the vertices array for each vertex that required its own normal (only true part of the time, if you are averaging normals), but this seems like a waste of memory and GPU processing.



You have to do that.

Regards,
-Lev

Share this post


Link to post
Share on other sites
Just add duplicated vertices...

(or wait for OpenGL2.0)

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
And to answer my own question, in case anyone else is running into this same thing:

http://www.opengl.org/developers/faqs/technical/displaylist.htm#disp0150

"Because vertex arrays let you access a set of vertices and data by index, you might believe that they''re designed to optimally share vertices. Indeed, a programmer new to vertex arrays might try to render a cube, in which each vertex is shared by three faces. The futility of this becomes obvious when you add normals for lighting and each instance of the shared vertex requires a unique normal. The only way to render a cube with normals is to include multiple copies of each vertex."

Share this post


Link to post
Share on other sites

  • Advertisement