Voxels and level of details

If you look at some of the most popular voxel games, I’ll say – totally randomly – Minecraft or Cube World, you tend to notice quickly that their camera range view is not exceptionnal, unless you have a 4000$ battle computer with a lot of memory and great CPU/GPU. It’s something that has always bothered me a bit, since I like games to have huge landscapes to show to the player. It’s something that helps a lot to increase immersion or at least to keep a coherent and believable world. It’s something that I’ll try to accomplish with Metaworld.

There are a few ways to improve a game camera range without killing your computer, and one of these is to implement a level of details system (LOD). LOD systems are a common graphic optimization technique in video games which consists in reducing the amount of triangles of the meshes to display. It’s a technique implying some quality-loss, but it’s supposed to be primarily used on meshes that are so far away from the camera that their details can’t be precisely distinguished in the first place.

A chunk in Metaworld is currently 32 voxels wide. The most obvious solution to simplify the generated meshes is to divide the chunk precision by two to have a second detail level (16 voxels wide where 1 cube = 2 voxels), then two again (8 voxels wide where 1 cube = 4 voxels), etc, until the geometry is not detailed enough to be interesting to show.

LOD Problem
Early implementation of the LOD system generated some… Interesting bugs. I “just” forgot to resend the vertex and index buffers to the graphic device after a LOD change.
LOD Transition
Transitions between two chunks of different LOD creates some gaps in the meshes.

Regarding the above issue of gaps between meshes – on which one I struggled a bit – I tried to simplify as must as possible the problem, since it’s often a good path toward a solution. One of the major simplification is that I only needed to care about the transition from a high detailed chunk to a lower detailed one. This is the typical LOD case, after all. When creating such a system, you want the chunks close to the camera to be detailed, and those far away to be less detailed. There are no common case where you should care about the transition from a low detail chunk to a high detail one, that would imply that the LOD is reversed.

In the end, it took me two days to have a LOD system satisfying enough, but the memory cost has been divided by 4. Worth it, I can now display farther than before :)

LOD Above view
As you can see from above, the voxels around the center of the screenshot is far more precise than the those from the outer parts.
LOD Perspective
You can see some LOD transition on the left, and the back. It’s going from a LOD of 1 to a LOD of 16.

Leave a Reply

Your e-mail address will not be published.