Jump to content
  • Advertisement
Sign in to follow this  
Silverlan

Vertices with multiple UV coordinates and glDrawElements()?

This topic is 1418 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 this thread, 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
Advertisement

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

Thanks.

So in essence, vertex attributes cannot be defined independently and if one vertex has similar attributes as another one, those attributes will have to be duplicated?

Share this post


Link to post
Share on other sites

Correct, and correct. Although, I don't look at it as duplicating those attributes because they happen to have the same value. They are only a part of a whole vertex, and only whole vertices can be subject to duplication.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!