• Advertisement
Sign in to follow this  

Indexing multiple VBOs

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

Hey you magnificent people !

 

I'm probably being a big dummy-dumb about this, but when using multiple VBOs for positional coords, normals, uvs etc - how would I use an index buffer correctly? Assuming only one IB can be used per draw call, is there any way to offset the buffer steps for each attribute so that a set of indices can be used for each vertex? If IBs can only hold one pointer per vertex then it seems to me like they wouldn't be very useful for more complex vertex definitions.

 

- Dave

Share this post


Link to post
Share on other sites
Advertisement

.obj file?  One solution is to introduce duplicate data so that you can address everything with a single index buffer.  This may also be faster - despite having more data - because it would allow you to interleave your vertex attributes, rather than using a separate buffer for each.  Another solution is to use a second layer of indirection with vertex textures, such that the value for each vertex attrib is a single float used to lookup a vertex texture giving the final value.  But in general it can't be done with a pure index-buffer-only solution - you're restricted to a single index buffer per draw call.

 

So, you're partially on the right track in thinking that a purpose of index buffers is to reduce the number of vertices, but you're totally on the wrong track in thinking that this is the only purpose of index buffers.  A second purpose of index buffers is to concatenate multiple primitives into a single draw call.  Consider a model that may be composed of multiple triangle strips and triangle fans; without an index buffer you'd need to do a separate draw call for each strip or fan, with one you can handle the entire model in a single draw call.

 

I touched on an important point there, and that's that memory saving isn't everything.  This may seem counter-intuitive, but sometimes it's better to accept extra memory usage in exchange for a faster algorithm.  .obj models in particular are misleading, as the format is optimized for storage, not for drawing - it's a lousy format for drawing.

Share this post


Link to post
Share on other sites

For the most part, you're best off using a single interleaved VBO unless you have some special reason for needing some of your vertex attributes to be in a different VBO. Examples of such reasons might be software skinning where positions and normals have to be in a dynamic VBO, while UVs and colours are better off in a static one, or an instancing situation where you have lots of objects with identical positions and normals, but they each have different pre-baked lighitng.

 

For the vast majority of cases it's a bad idea to use multiple VBOs, and you can't index the components separately (although it's not dummy-dumb to think you can, I know of at least one console which supported it, and it did save a lot of memory).

Share this post


Link to post
Share on other sites

Thank you guys for the clarification. It seemed strangely difficult to find a clear answer elsewhere, but this makes me confident to continue my research. Saludos !

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement