I'm currently trying to do a basic "minecraft style" game. I know how difficult it is to create a game like this, that's why I juste want to do the base of a game like this. I did a class which creates one block face, another one which handles the creation of the whole block (All the faces), and a Chunk class which stores and renders all blocks.
My chunks are 16x1x16 sized (Just 1 layer of blocks). I did a first optimisation step : I removed all faces that aren't visibles (If two blocks are sided, I don't add the two sided faces). And another optimisation with the frustrum.
One chunk rendered Removing invisble faces
With one chunk rendered, framerates are good, but above 4-5 chunks rendered, framerates are becoming low. I don't know how to optimise more. I heard about VertexBuffers and IndexBuffers, but I don't know how to add them, because I have a lots of Blocks, in a lots of chunks. And maybe, in the future, how manage that if I want to destroy/place blocks ?
So my question is : How I can optimise the game ?
Thank you !
(Excuse my english, i'm a French guy eheh)
The biggest difference is using VertexBuffers/IndexBuffers. You'll want to draw each chunk as a single Buffer. If you want to destroy-place blocks, you just re-calculate the VertexBuffer and
setData with new data.
You'll want taller chunks. The optimization where you remove all the internal faces works a lot better when you have more internal faces. With 1-block-tall chunks, you're always rendering the internal top faces, which you don't need.
Depending on how your shader works, you should be able to merge individual 1x1 squares on the surface into larger rectangles. This blog post shows some comparisons on how the mesh size gets reduced by this optimization.