Category Archives: Voxel Engine

From voxels to triangles

Voxels are hot topic. Ever since the minecraft game ‘voxels’ are popping up everywhere. The technology is not new, but with the power of modern-day GPU’s, advanced techniques are now possible in real-time.

I was particularly impressed by the works of ProcworldVoxel Quest and Blockscape. Since this technology requires combining computer graphics, maths, CPU/GPU parallelism and complex algorithms, I was very excited to taste some of those delicious voxels myself!

Player build from landmark, made possible with the procworld engine.
Built by players in Everquest Landmark, a game made possible using Procworld voxel technology.

Voxels are the three-dimensional equivalent of 2D pixels on your screen. Your screen is divided in a finite set of points (hopefully at least Full HD 🙂 ). Each point corresponds to a dot or a square with a single color. Put all of these millions of points together and you get an image.

Voxels follow the same principle. The 3D world is divided using a regular (equally spaced) grid, and each gridpoint corresponds to a single voxel. Instead of containing color, a voxel typically holds the type of material present at this point, like grass, dirt, rock, air, but a voxel can be used to store any kind of volumetric information.

CubeGrid
6x6x6 voxel grid of a cube with voxels displayed as small boxes. White boxes represent air, green boxes represent solid material.
21x21x21 voxel grid of a sphere.
21x21x21 voxel grid of a sphere.

I deliberately didn’t refer to voxels as cubes, since they aren’t. Voxels can be represented as cubes, by placing a cube at each voxel using the voxel’s material (as done in Minecraft). However, alternative techniques exist, Procworld converts the 3D voxel information back to 2D triangles by generating the surface between air and solid. I’m guessing blockscape stores different shapes of cubes in its voxels and displays those. Voxel Quest is using some sort of ray marching algorithm and evaluates 3D mathematical functions.

For my implementation, I started with a surface extraction approach as in Procworld, since it has as a main benefit that it outputs triangles, making it compatible with most mainstream 3D rendering technologies. This way I can render the voxel world using my existing deferred rendering implementation.