Archived

This topic is now archived and is closed to further replies.

Index Buffer?

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

How does this "index" buffer differ from the traditional Vertex buffer? I''m looking to create a world like atmosphere and it would be a bit difficult using triangles to create everything I was reading through the DrunkenHyenas online tutorials, but couldn''t find anything that covered that.

Share this post


Link to post
Share on other sites
Index buffers are used with vertex buffers, so that a single vertex can be used multiple times during single draw call.
It doesn''t, therefore, replace the vertex buffers.

-Nik

Share this post


Link to post
Share on other sites
I could explain a whole bunch of info on an index buffer here... but why not just show you the ultimate power of GOOGLE??!!!

I am assuming you are using d3d since you were looking at DrunkenHyenas tuts.

[edited by - curtmax_0 on October 16, 2003 11:46:13 AM]

Share this post


Link to post
Share on other sites
Why would I use google when we have a forum here? Why would anyone post anything here. You could find everything you ever needed on a search engine. But I come here for the advise and opinions of the individuals on this board, not to hear about people telling me to look elsewhere.

Share this post


Link to post
Share on other sites
Hi,

I couldn''t draw a diagram on this subject
However, i give an example.

Consider 4 vertices, numbered 0, 1, 2 and 3.
The vertice''s positions are assumed to be in clockwise order.

Now, how would you draw a quad (list of 2 triangles), with this data, without duplicating the actual vertices?

Answer: Make a index buffer the size of 6 indices.
The first triangle''s indices are 0, 1 and 2.
Second triangle''s indices are 0, 2 and 3.

Now, the vertices 0 and 2 get to be used twice in the same draw call. Because indices take much less space than vertices, this is a memory advantage.

Other, non-obvious effect of the indexing is that when a vertex gets thru the video card''s transformation stage, it is stored in a cache memory for a short while. If the same vertex is used while it''s transformed counterpart is in the cache, it doesn''t have to be transformed again.
This is a speed advantage, and usually a surprisingly significant one.

The single quad is too simple to benefit at all from indexing. But in real mesh, as many as 30% of the vertices may be used in more than one triangle.

-Nik

Share this post


Link to post
Share on other sites
See that sorta makes sense! Thanks Nik, you always help me out.


D3DVERTEX aCubeVertices[ ] = { {-1.0f,-1.0f,-1.0f,0.0f,1.0f},{-1.0f, 1.0f,-1.0f,0.0f,0.0f},{1.0f, 1.0f,-1.0f,1.0f,0.0f},
{ 1.0f,-1.0f,-1.0f,1.0f,1.0f},{-1.0f,-1.0f, 1.0f,0.0f,0.0f},{1.0f,-1.0f, 1.0f,0.0f,1.0f},
{ 1.0f, 1.0f, 1.0f,0.0f,0.0f},{-1.0f, 1.0f, 1.0f,0.0f,1.0f}};

short aCubeIndices[ ] = {0,1,2,2,3,0,4,5,6,6,7,4,0,3,5,5,4,0,3,2,6,6,5,3,2,1,7,7,6,2,1,0,4,4,7,1};


so these 8 Vertices are all referenced 0-8? and then in groups of 3 those Indices are applied to make a triangle!? Thats much easier.

[edited by - EasyGino on October 16, 2003 5:02:58 PM]

Share this post


Link to post
Share on other sites
A cube is an unfortunate shape for index buffering, since you still have to have duplicate vertices at the corners (because of different normals at each cube face).

However, i see that you got the basic idea though

-Nik

Share this post


Link to post
Share on other sites
Ok, now would i map a "terrain" with tons of vertices first? maybe in some kind of loop, and then plot the indeces with some kind of algorithm that would make a rocky terrain?

Share this post


Link to post
Share on other sites
That i leave as an excercise for you. There''s no right or wrong way for terrain generation, just do what you believe you need.

For "rocky" terrain, move the vertices by some noise-type function.

And yes, a loop system would be ideal in distributing the terrain vertices

-Nik

Share this post


Link to post
Share on other sites
Texture coordinates go with vertices as usual, why do you think it would be more difficult?

-Nik

EDIT: I'm going to sleep now (it's almost 1am here). Hear you tomorrow!

[edited by - Nik02 on October 16, 2003 5:46:39 PM]

Share this post


Link to post
Share on other sites