# Greedy Meshing : Slow to rebuild when updating chunk

I've a problem with my voxel based game. The game is sliced into chunks (Like Minecraft), each chunk is 16x256x16 blocks.
When I started the project, I used a basic culling system when hidden blocks where not sent to the chunk buffer. It was running well, the only problem was my memory usage, even with the culling algorithm, the amount of vertices was incredibly high and it has a real impact on the memory (16x16 chunks loaded -> 2-3go ram in usage).
So I decided to move with the greedy meshing algorithm, after the implementation the memory usage problem was solved (16x16 chunks loaded -> 200-300mo), however a new problem appears and I don't really know how to solve it.

Each time I place/break a block, I need to update the chunk mesh in order to recalculate each vertex position. But greedy algorithm is not as fast as the culling one. So when I place/break a block, the game freezes for less than 0.1ms. I know the greedy meshing algorithm is a slow process, especially with a 16x256x16 sized chunk.

Here's where my greedy algorithm come from :
https://0fps.net/2012/06/30/meshing-in-a-minecraft-game/

So, do you think the problem come from the fact that my greedy algorithm is not optimized ? Does the greedy algorithm is really necessary ?

Hope one of you can help me !

Thank you guys !

• Funnily enough, I'm using the culling algorithm and it isn't actually that slow IMO. The greedy algorithm just seems so hard to implement, that wouldn't really be justified by the slight speedup. Keep in mind, modern GPU's slowdowns are in the CPU-GPU communication, not the actual rendering. So as long as everything is in a single mesh, you should be fine. – mackycheese21 May 1 at 15:36
• Actually: if the rendering is simple (like a single texture lookup per fragment) then what I said is true. This seems to be the case for your game. – mackycheese21 May 1 at 15:36
• And are you storing the mesh data on the CPU after uploading it to the GPU? Because once the data is sent to glBufferData or whatever you're using to upload data, it doesn't need to be stored on the CPU. It can be deleted / freed / leaked. – mackycheese21 May 1 at 15:38