Sign in to follow this  

Vertices with multiple UV coordinates and glDrawElements()?

This topic is 1196 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

This is essentially the same problem as the one described in [URL=http://www.gamedev.net/topic/165704-vertices-with-multiple-uv-coords-and-gldrawelements/]this thread[/URL], however, seeing as the thread was started in 2003, things may have changed by now.

 

Basically, the problem is that my model can have multiple UV coordinates for vertices which are used by more than one face.

I'm using glDrawElements, but I'd like to avoid having to duplicate my vertices, just to fill it up to correlate with my UV coordinates.

 

Is there a way to use a separate index buffer for the UV coordinates and use that in conjunction with the main index buffer for the vertices?

Or is there an alternative altogether?

Share this post


Link to post
Share on other sites

Short answer; no, these things have not changed since 2003.

 

The thing is, a vertex is defined as everything that defines it, not just its position. The position attribute of a vertex, and the vertex itself, are often used for the same thing. Sometimes that's correct, but in the context of OpenGL, that is not correct. The position attribute of a vertex which many faces may share all over the model is just that, the position attribute of a greater atomic entity.

 

When you say that you have two identical vertices with the same position but different color, you really have two completely different vertices. So you're not duplicating any vertices, because the two vertices are different.

Share this post


Link to post
Share on other sites

It's worth adding here that the natural impulse to "not waste memory" by eliminating this kind of duplication can sometimes lead to worse performance.  Memory isn't the only arbiter of performance, and sometimes choosing to burn the extra memory in exchange for a more sequential, more cache-friendly layout that's in a format the GPU can work with more easily will give significantly higher performance gains than anything that could be theoretically obtained by saving memory.

Share this post


Link to post
Share on other sites

This topic is 1196 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this