Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Indexing multiple VBOs


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Vanderry   Members   -  Reputation: 213

Like
0Likes
Like

Posted 05 January 2014 - 02:26 PM

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



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8141

Like
3Likes
Like

Posted 05 January 2014 - 04:09 PM

.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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 C0lumbo   Crossbones+   -  Reputation: 2398

Like
2Likes
Like

Posted 05 January 2014 - 04:27 PM

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).



#4 Vanderry   Members   -  Reputation: 213

Like
0Likes
Like

Posted 05 January 2014 - 04:48 PM

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 !



#5 Edin M.   Members   -  Reputation: 458

Like
0Likes
Like

Posted 07 January 2014 - 02:12 PM

http://www.gamedev.net/topic/602159-vbo-obj-3ds-and-some-concept-questions/#entry4811696






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS