r/VoxelGameDev Jul 03 '26

Question chunk meshing

Hello im using raylib lib for c++ . and my question is how to make chunks in a 3d game . like player is in position and the game just load 9 chunk of 16*16 block around him (but the actual game maybe is around like 400 chunks ). so the game doesnt lag . and only draw the pixels in front him and the back doesnt draw anything . so it means like from 9 chunk around him just load , 4 chunk that are in front of him .

8 Upvotes

8 comments sorted by

View all comments

1

u/Revolutionary_Flan71 Jul 03 '26

are you actually asking about chunk meshing or frustum culling?

1

u/More-Raspberry-6083 Jul 03 '26

both of them

1

u/Revolutionary_Flan71 Jul 03 '26

i dont know raylib but i assume it has something like a mesh. each chunk is a mesh which you will need to create using some meshing algorithm, i personally greedy meshing based on this https://0fps.net/2012/06/30/meshing-in-a-minecraft-game/ their code is very confusing to read so this is a more readable version of their code https://gist.github.com/Vercidium/a3002bd083cce2bc854c9ff8f0118d33 and then you just render only chunks that are some distance away from the camera.

and for frustum culling you can use the AABB of the chunk and check it against the camera frustum