Understanding Voxels


Photo by Ryan Quintal on Unsplash

Recently I found myself answering a question from my kids about the block style in Minecraft. To which I was not able to answer them the way I wanted. So after some research, I feel better about what voxels are and what they are not.

Voxels are similar to pixels that divide a two-dimensional plane into their smallest area and filled with color. A voxel is also a division into the smallest region, but instead of a two-dimensional space, it is in three-dimensions (X, Y, and Z). Just think about it like a pixel rendered in 3D, Which is just a cube. Also, when a voxel gets displayed on the screen, the location data for that voxel is relative to other voxels around it and the data structure holding the voxel information. This corresponding location data is different than a standard 3D mesh in a scene where the location data gets embedded into the model.



image provided by wikipedia

A deeper dive into voxels

Voxels are very similar to pixel-based development. In a pixel sprite sheet, you just have a set height and width canvas, and the scene is displayed on the screen for you. The developer then creates the fancy 2D character, like Mario or some other excellent character by just filling out the pixels into the color and create the image once all the colored blocks are placed together. To create those transparent spaces, in-between a “key” color is used to mark a color as transparent. Usually, pink color is often used to say it should be rendered as invisible. Depending on the color palette available for Voxels, you can also use a key method or use alpha and create a transparent result.

As mentioned above, Voxels are basically like pixels except in 3D space. Your object is then a three-dimensional space cut up into equally space cubes. You then create your object by filling out the smaller cubes until you get the appearance you want. Think of those pictures you have seen that are just tiny color cubes, but when you zoom out, it ends up creating an image.

image provided by freesvg.org

There are many ways to increase the level of detail for your voxel creations. One of the easy ways is by increasing the number of cubes that make up your object. For example, it is not very impressive to have a block that is cut up into four smaller cubes, creating only the ability to show four different colors max. You could double that by dividing all those cubes and have eight blocks max. To increase the detail, just decide how many divisions you want to have in the end. Note that whatever your division you choose is what you will most likely need to keep for all other objects since you have to divide the entire game world into equal cubes.

If the dividing cubes sound familiar, think about the original consoles. Nintendo was capable of showing 8-bit color graphics. Super Nintendo doubled that with 16-bit graphics, and we got the fantastic 64-bit graphics introducing 3D worlds with the Nintendo 64. Try using that as a mental model if the lego analogy doesn’t work.

Handling Location Data for Voxels

In the more recent development of games and 3D experiences uses the idea of meshes built-in programs like Maya and Blender. These meshes, all of the coordinates specify their location themselves to tell the system how to show the 3D models and the game for the player. In Contrast, voxel-based games are built by having the location data outside of the models and in a separate data model called a multi-dimensional array. If you have ever had to do matrices in math class, it is kind of like that.

This fancy array contains the block information to tell the game engine where the blocks are and what block should appear in that spot. So what does a three-dimensional array look like in a game? Well, check out the representation I have created. It is nothing surprising, but its suppose to represent the smallest block size in an x,y,z space and then equally divide it up

[(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),

(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),

(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z),(x,y,z)]

This represents a 5×3 world, a very small world.

You can then say AtLocation[0][0][0] = “Grass Block” in the code. This representation hopefully helps see why it is so easy to swap out blocks with other types. Technically in games like Minecraft, what you are doing is breaking it down to a clear block. And then placing a new block there. AtLocation[0][0][0] = “Clear Block” then AtLocation[0][0][0] = “Stone Block” would be the example where a stone block was replaced where there was a grass block. The program doesn’t care what block it is, and the graphics renderer is responsible for translating the data from voxel to show on your monitor. In this example, [0][0][0] is pointing to the place the first block is placed in your world. That could be in a top corner in a fixed-sized map. Or a center point that expands outward and is added onto as the world gets generated when the player explores.



Voxel’s In Video Games

Minecraft is currently one of the most well-known examples of voxel-based games. It was popularized by Notch from Mojang, creating a sandbox game that lets players build whatever they wanted. The game is relatively straightforward code wise and is why it has become super easy to mod for players to play they want beyond playing it in classic survival and your dirt house. All elements in the game from blocks to tools are done in voxels.

Minecraft Logo from the Game’s Title screen

There are still plenty of other ones out there like Crossy Road, CubeWorld, Boundless, Stellar Overload, StarMade, Space Engineers, and the list goes on. Games are being made all the time that are using the voxel style. Check them out and support your fantastic indie game developers!

Voxel’s Outside Of Video Games

Outside of games, there are some great uses for voxels. One of these might be something you are already familiar with, Magnetic Resonance Imaging or MRI’s. They create a voxel element from the signals sent scanning the person. The data received transformed the intensity of the scan. Think of echolocation where the response from what it hits has a different message that can help to generate a map. In this case, it is then turned into a voxel image of the person scanned. Amazing!

Scientists around the world use voxel-based models to create representations of how fluids and other simulations work in an attempt to try to create a model to explain why something behaves a certain way.

It is great to see things be expanded beyond the standard way we see them.

3T MRI Machine image provided by Wikipedia

Voxel editors

So, of course, if you want to get started playing with Voxels, there are now editors focused on just making voxel models. Feel free to take one for a spin and let me know how it goes!

MagicaVoxel – Free

Voxel Max – Currently in Beta, Voxel modeling on your phone or tablet.

Qubicle – Indie

VoxEdit – Free!

Sproxel – Free

Goxel – Free, Open Source

Particubes – In Beta, Free, when released a premium version is available for $5/mo

The number of editors trying to incorporate the word Voxel is impressive. There are many more than this online as well, so feel free to find out more if you are interested.

I hope you enjoyed this article if you did, please share this with someone you think would appreciate it. Have a correction? Or want to help improve this article, leave a comment or message me via Contact Us, and I can get it corrected. Thank you all for reading. Stay Awesome!



Recent Content