1
\$\begingroup\$

I want to know what technique will give me most fps in game. I have minecraft-like world and I need to display it. Now I have only one cube, created as VBO and if i need to display cube I just display it. But now I want to know what will be faster:

Create for each cube type VBO (even for each side of it) or to create new VBO each frame for whole mesh to display?

I am very new to subject so if there are other faster techniques let me know. Thanks in advance.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

This is not a simple question - but the philosophy is simple - seek out like things and bundle them together so that the pipeline never starves for data nor stops to change gears.

Secondly, do NOT create the same thing again and again - if you have a cube, build the vertex buffer and index buffer once - use instancing, and use the world matrix to change location, size, and orientation of the cube.

If you have many cubes that never move, then preprocess them to incorporate their position in the world into their vertices proper - i.e., you are changing from project*camera*world to just project*camera

If you have many cubes that all have the same texture or material, consider bundling them all up into one vertex buffer - course this is assuming you're never going to fiddle with the geometry

Use constant buffers whenever you can - organize things so they change only when they have to - never load them with the same data all over again - sort things so that like comes through the pipeline with like

At the end of the day, your final techniques will likely be tuned to the nature of your application - you'll do what you need to do to keep those pipes flowing in the gpu as efficiently as possible

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for answer, but it a little vague. I have only cubes to display. But I want to do culling based on connection between cubes. For example if cube (x, y, z) have neighbour at (x+1, y , z) I don't want to display its right side. So I'll be (1)forced to change index buffer everytime and push it to graphic card for each cube or (2)create 6 index buffers one for each side but do up to 6 drawing calls for each side or most hardcore(3) create 2^6 (64 - all permutations of visible) index buffers and do one call for each side. Seems like 3rd one is best optimization, but I need aprove to start it \$\endgroup\$ May 17, 2013 at 18:38
  • \$\begingroup\$ You would only need to update the index buffer if you are updating the block. When the block changes, update the Vertex and Index buffer, send it to the card, then forget it until one of those two blocks (or ideally, any block in that chunk) is updated again. \$\endgroup\$
    – Phil
    May 17, 2013 at 23:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .