c# – 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 (16×16 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 (16×16 chunks loaded -> 200-300mo), however a new problem appears and I don’t really know how to solve it.

Solid
Wireframe

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 !



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *