This is a basic introduction to what voxels are, what they are not and their general use cases.

If you wish to know the history of voxels, see here.

What is a voxel in theory?

To quote Wikipedia:

Voxels In 3D computer graphics, a voxel represents a value on a regular grid in three-dimensional space.

— Wikipedia on Voxels

Since most people don't have a good understanding/foundation of math (in this case: linear algebra), let's explain this piece by piece.


A voxel represents a value...

An individual voxel can be absolutely anything. Yes, anything.

And of all this is without taking the encoding, be it in-memory or on-disk, into account.


A grid of voxels containing colours.

CC-BY-3.0

...on a regular grid...

Taking the definition from Wikipedia...

A regular grid is a tessellation of n-dimensional Euclidean space by congruent parallelotopes (e.g. bricks). [...]

...and breaking it down:

  • Tessellation
    The grid is formed by dividing space into cells.
  • n-dimensional
    The grid has at least one dimension.
    But since we are in 3D space, at least three.
  • Euclidian space
    The axes are at 90° degree angles to each other, everywhere.
  • Congruent
    Every cell in the grid has exactly the same shape.
  • Parallelotopes
    • The cells are shaped like boxes.
    • Each opposing side has the same area/shape.
    • Their edges in a given axis are parallel.

Now you might think that the cells of the grid are the voxels, but that is not the case! The voxels are theoretically on the corners where the cells meet, they are neither inside the cells nor are they the cells; a voxel is a point sample, not a little cube.

In practice you will usually notice this when either rounding or off-by-one errors occur.


...in three-dimensional space.

  • There must be at least three-dimensions, so as to form a volume.
  • Adding more spatial dimensions turns the voxels hyper-volumetric,
    making them hypervoxels (there is no shorthand or acronym for this).
  • Adding a time-dimension turns them into temporal voxels,
    making them toxels.

That is the definition of a voxel; and if that all sounded complicated... well that's because it is! Mathematics are like that sometimes.

What is not a voxel?

Every now and then, someone thinks they are dealing/working with voxels, when they're in fact not doing so...


Heightmaps Are Not Voxels

If values are generated in a two-dimensional grid and expanded into a third dimension on-demand, such as during rendering, you are not using voxels.

That's just a plain old heightmap pretending to be voxels!

Important:
This does not mean that columns of values arranged in a grid, like run-length encoded data might be, aren't voxels! The way that voxels are stored does not matter as long as the grid is indexable.


Individual Voxels Have No Position

If one defines individual voxels with an explicit position, like...

struct Voxel {
  position: (i32, i32, i32),
  value: ???
}

...then that's not a Voxel, by definition.

It's also really, really bad for performance. Don't do this.

Let me repeat: Don't do this.

Volume = Distance ³

A fundamental reality of many voxel algorithms is that the data they deal with cubically1. What does that mean, in practice?

Let's do a tiny bit of math (feel free to grab a calculator):

  1. Think of how far into the distance you want to 'see', in meters/voxels.
  2. Using that distance, calculate (D*2)³ to get the visible volume.
  3. Assume a voxel takes just a single byte of space...
  4. Divide by 1024 to get it as kilobytes.
  5. Divide by 1024, again, for megabytes.
    • Divide again to get gigabytes, if needed.
  6. Look at the amount of memory used.
  7. Change the distance and repeat a few times.
Fun Fact: Planet-sized Volumes

If you solve the volume for the size of the earth (a radius of 6371km), you will get a fun number of roughly 2068 exabyte... which is roughly seven percent of the world-wide-webs entire contents (in ~2024), at about 27000 exabyte!

Luckily, most of any planets volume is unreachable, hidden under the surface, so it can be treated as if it didn't exist, vastly reducing the needed volume.

While computers these days are pretty darn powerful, they still have limits, and working with voxels can push them there very quickly...

  • Your RAM may be large (many gigabytes, usually ~4-8 GB),
    but the bits'n'bytes still need to go to/fro the CPU and back.

  • Your CPU may be fast (billions of operations per second),
    but even the fastest processors will weep at O(n³).

  • Your GPU has a whole lot of cores, but efficiently using them is... complicated. Also, VRAM is hella expensive.

So keep the law in mind when writing yet another for(voxel in volume), or your CPU might just go up in flames. ;)


What are voxels used for?

Many things, but three of them stick out:

Since you are visiting this wiki, you might already know what you intend to use voxels for; if not, please take some time to think about it, otherwise just read on ahead! :)

For the creation of voxel art, we highly recommend checking out MagicaVoxel, which is currently considered to be the best voxel-editor you can get; it's completely free!

Perhaps share your creation?


Next

Choosing a programming language!