Jump to content
  • Advertisement
Sign in to follow this  
cNoob

vertex buffer improvement

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

Ive been messing about with my vertex buffer making aload of cubes in 3d space. It was then that i relised that i have vertices being used more than once for each cube. I was woundering if this would slow my program down if so is there a way to improve the speed of my program. Any help would be great.

Share this post


Link to post
Share on other sites
Advertisement
You should be using an index buffer also.

Consider your cube and how it has a total of 8 vertices.
So we label each vertex. 1, 2, 3, 4 ...
And you said that some of the vertices are the same.
So maybe we could say one side has two triangle built like this:
1, 2, 3
2, 3, 4

Notice that the 2 and 3 vertices are the same and are used in both triangles.

Well this is exactly what an index buffer is.
Without it your vertex buffer would be like 1, 2, 3, 2, 3, 4
With it your vertex buffer would be like 1, 2, 3, 4 (no overlaps)

And then you add the index buffer which has 1, 2, 3, 2, 3, 4

There are many benefits to this like the fact that 2 and 3 will be in vertex cache and so they don't have to be recomputed.

Share this post


Link to post
Share on other sites
thanx guys ill search google for index buffer tutorials. Any of you got any links to what could help me out

Share this post


Link to post
Share on other sites
The DirectX SDK documentation provides a wealth of information. For example, see the Rendering from Vertex and Index Buffers topic.

Illco

Share this post


Link to post
Share on other sites
Keep in mind that a vertex is more than just its position. It may also include a normal, colors, and texture coordinates. So, just because two vertexes have the same position, it doesn't always mean they can be the same vertex.

Share this post


Link to post
Share on other sites
Quote:
I was woundering if this would slow my program down if so is there a way to improve the speed of my program. Any help would be great.
.
This really does depend on how many primitives you are rendering. If you are rendering 2 primitives... using an index buffer might be overkill. So use your own discretion when making this decision such as... "right now I have almost 200 000 primitives being rendered, I think using index buffers will improve my 10 000 duplicated vertices."

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
im making just a simple random terrain and i needed sharded vertices so i could set the random y values. My terrain will be 32 tiles across and 32 tiles down so does that mean using an index buffer would be more efficient

Share this post


Link to post
Share on other sites
Quote:
Original post by cNoob
im making just a simple random terrain and i needed sharded vertices so i could set the random y values. My terrain will be 32 tiles across and 32 tiles down so does that mean using an index buffer would be more efficient

I don't think it would make a huge amount of difference. Not for those sorts of numbers on modern hardware. Yes, it might go a bit faster - but what does it matter if it's already clocking up a high frame rate? Might be better to wait until it is a known performance problem before you go about changing it.

One area that IB's can help with terrain is if you intend to dynamically update the heights (esp. if you make your water/ocean a form of heightfield). Having 6 triangles sharing a single vertex rather than 6 unique vertices means you have less data to manipulate/write/upload.

hth
Jack

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!