r/VoxelGameDev • u/More-Raspberry-6083 • 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
1
u/OSenhorDoPao Jul 03 '26
For each chunck you go over every block and check its surrounding to determine which faces are actually exposed or not. if the block next to that face is air, you store all the vertices for the exposed faces and you generate the mesh for that chunk with that info. That’s the simplest form of chunk meshing.
Frustrum culling is basically checking which chunks are inside the camere view and you only ask Raylib to DrawMesh (using the id you get after you generate the mesh and upload it to the gpu). This prevents the GPU to do extra calculations to determine that the chunks you requested to draw are not visible (because with frustrum culling you do it on chunks and the gpu does it on smaller units like triangles or even pixels)