Voxels (volume elements) are the 3D analogue of pixels - they are regular units of volume with associated data, as pixels (picture elements) are regular units of area. They are often arranged in tightly-packed regular grids, but this is usually more of a convenient mental model then a method of storage as it can take a lot of memory to provide sufficient detail. The key difference between voxels and polygons is that polygons define an explicit boundary as a set of points, whereas voxels are regular samples and so their positions in space are inferred from their location within a data structure.
I have experimented with voxels as a means of storing geometric data from which images can be directly rendered in realtime. I will no doubt revisit voxels in this context again in the future, probably by adapting my old code.
Large Voxel Environments (May 2009)
This an implementation of the method described in the Gigavoxels research publication. It streams voxel data from hard-drive. I called it 'Magma'. Voxel data is compressed to 6 bits per voxel using chroma subsampling in the YCoCg colourspace and a quantization similar to that found in S3 texture compression. There is some simplistic precomputation of lighting in the conversion from a triangular mesh format to volumetric format. It is a little limited in terms of scene authoring (the advantages of voxels are not fully exploited), but it demonstrates octree raycasting on CUDA. As this was an early attempt at voxel modeling, raycasting, and GPGPU programming there is much room for improvement and redesign. Furthermore, as I knew little about CUDA at the time I created this and CUDA was relatively new anyway, I had to use Microsoft Visual Studio to develop it. Support for GCC was not so good at that time.
The scene format for this engine was designed to be streamed, and to be quickly seekable (random access is a must). As such, the level of compression achieved was not maximal and I've found that compressing a complete conversion of a Quake 2 level into a ZIP archive takes the file size from 106 megabytes to 22 megabytes. This would be good for a videogame in which only one of the files would be needed at a time - only one uncompressed scene is required to be resident in memory at any instant.
The colourful Magma engine
'Unique Detail Everywhere' is an advanced voxel model editor which I started to produce in order to produce better scenes for Magma. It uses GTK for the user interface with an embedded CUDA/OpenGL viewport. It has a modular design and a shading language, the execution of which is sped up by the use of GNU Lighting which is a library for produced JIT-compiled programs. The design focuses on a flexible and functionally-based approach to modelling. I was deeply inspired by the functional representation of 3D graphics, and how expressive it can be. I planned to have many levels of abstraction so that at the deepest level would be the evaluated user-written shader functions, and at the top would be the visually-driven modelling tools which they compose. The shading language itself was inspired by common realtime graphics APIs such as Direct3D (HLSL) and OpenGL (GLSL). It features many of the same functions, often with the same names. Some of the ideas I had for this application I would later use in the design and implementation of BoxTool.
Unique Detail Everywhere
Further Large Voxel Environments (Volboxes) (August 2010)
Recognising that GPU programs work best without dependent branches, I tried making use of both the GPU's efficient rasterisation and programmability in a program I called 'Volboxes'. In Volboxes, cubes are rasterised by hardware, then rays are cast through the cubes. Each cube has an associated 3D distance field defined as a volume texture. It turned out to be relatively fast, but the project has not progressed to a stage where authored scenes may be imported or converted. A filtered distance field / native 3D texture fetch reduces aliasing due to geometric discretization.
My Volboxes test scene demonstrating curved surfaces
Raycasting of Instanced Voxel Models on CPU (August 2011)This is my most recent voxel-related coding endeavour, and is the least interesting. This program uses regular uniform grid traversal algorithm also known as 3D Discrete Domain Analysis. This is a 3-dimensional variation of the DDA algorithm used for Wolfenstein 3D. There are no special optimisations other than the offsetting of ray starting points to model bounding boxes (an analytic ray-versus-box intersection). The model format is pretty flexible, but the rendering times are relatively slow although the images do not suffer from precision problems, and models can intersect without problems. Memory is saved by having multiple instances of the same model at any orientation and position. Ken Silverman's voxel format is supported.
"I'm Duke Nukem!"