What's the use of an index buffer?

Started by
6 comments, last by Cypher19 20 years, 3 months ago
I''ve seen index buffers here and there, and tried to find some more information in the MSDN library, but I can''t seem to figure out what the purpose, or benefit, of using an index buffer is. Anyone mind enlightening me?
Advertisement
Most models have a lot of vertices that are shared by many triangles. If you''re using a vertex buffer to send all of the vertices as you use them, you''re going to be sending the same vertex over and over - each one of them taking up a relatively large amount of your video bandwidth. If you instead first transmit each vertex used in the model once in a vertex buffer, and then use an index buffer to tell the video card which vertices to use in what order, you''re just sending a bunch of ints, which uses significantly less bandwidth.
I find that index buffers are also useful for LOD; I''ve designed (not implemented) a scheme for a simple heightmapped terrain engine that uses indices for different LODs.
If I''m not mistaken, indexed primitives allow DirectX to do optimizations based upon the type of data you send to the graphics card.

For example, with triangle strips you only need to know the first two vertices for the starting point, then after that all you need is just one vertex to define the next triangle. If you were using ordinary vertices, you''d have to send that vertex over the AGP bus once per frame. But, if you''ve got all your vertices stored in an vertex buffer (that resides on the card most likely) and is indexed, then you can just send indexes over to the card instead of the full vertex.

Index buffers are especially useful for complex meshes (typical for say, models of the player and enemies or other ingame objects), because if your mesh is static then all you need to squirt across the AGP bus is just a bunch of two-byte integers, instead of the 4 or more bytes for a typical vertex (XYZ, normal, plus diffuse, etc).

---
[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]
--- - 2D/Pixel Artist - 3D Artist - Game Programmer - Ulfr Fenris[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]
Whoa, no wonder they''re so popular! That''s one damn efficient method of storing them.
Referencing a vertex by an index also allows the GPU to setup a cache of recently transformed/lit vertices. It can use the index as the key to a cache entry and if the vertex is found in the cache it won''t have to transform and light the vertex again.

Heh, /me just repeating what Doughboy said. Though I am incorrect, most vertices are somewhere around 64 bytes, not just 4-5 bytes. Brain still stuck in single or double word fixed-point math I guess!

And, Don, that makes a lot of sense. Didn''t know that.

---
[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]
--- - 2D/Pixel Artist - 3D Artist - Game Programmer - Ulfr Fenris[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]
also note that the operations that perform on indexed primitives have a higher periority for the driver than the operations done on none indexed ones.or as ati papers say the index buffers are first class citizens.

This topic is closed to new replies.

Advertisement