voxel engine first devlog yayyyyyy!!!!!!
Deadahh just wanted to put everything from the last few days into one initial devlog so I don’t have to keep yap too much.
Started with basic OpenGL 4.6 and GLFW, instead of using string lookups for shaders which is clown behavior, everything uses explicit locations. I also set up a headless smoke test so the CI can render offscreen, check its own pixels, and pass without popping up a window and being too goofy.
For debugging, I threw in an ImGui menu to track frames, draw calls, and memory without making the heap allocator crash out. Steady-state heap allocations are at zero right now + also flipped the depth buffer to reversed-D because standard depth buffers kaboom at long distances and make the textures Z-fight.
The Mesher thingy
The first mesher I built was literally just a mesher. A regular mesher. There was nothing special about it. It just emitted 6 expanded vertices per face which took up way too much space (615 KB a chunk) and was slow.
I improved it and made a binary greedy mesher that packs an entire quad into a single 64-bit integer. It uses 64-bit bitwise column ops to merge faces instantly. 2.7x fewer triangles and 33x less memory. It’s so fast it takes like 0.05ms and I also ripped out VBOs completely for SSBO vertex pulling, meaning the GPU just reconstructs the geometry on the fly.
There was one issue where the greedy mesher left microscopic sub-pixel holes everywhere so I kept seeing pinhole cracks, so I just bloated every quad by 0.001 so they overlap and cover it up (surely this works well enough).
Chunks & Compressing
Having raw voxel arrays was eating my RAM alive, so I used palette compression. If a chunk is entirely air or entirely stone, it just stores one ID now. If it’s mixed, it bit-packs the indices, this dropped voxel memory by 20x. We’re streaming a 21x21x4 chunk radius (like 2,100 chunks) and it only takes 6.6 MB.
Added a chunk streaming manager so it loads in a ring around you. I had to put strict budgets on generation and meshing per frame, otherwise the game just freezes when you move too fast + CPU frustum culling means we only actually draw the chunks you’re looking at.
What’s Next?
Right now the engine is in the state of being too good and being too bad at the same time. It’s doing like 349 individual draw calls per frame (one for every visible chunk). It works, but it’s got some quirks that I need to kaboom first.
Next up is building a persistent arena buffer and GPU-driven culling so we can collapse the entire world into ONE single draw call using indirect drawing.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.