Screenshot (with surface normal inference)

OpenCL Voxel Raycaster

I started this project mostly in order to familiarize myself with OpenCL (which I find I prefer to CUDA), but also to answer a question: "is it possible to perform real-time voxel raycasting on the GPU?". As I've learned, many other people have wondered the same thing, and there are several voxel raycasters floating around on the web. Like many of these, the basic data structure which I use is a Sparse Voxel Octree (SVO), although I made a few "tweaks" to improve performance.

The most important of these is that the leaves of the tree do not represent individual voxels--instead, each holds a 4x4x4 grid of voxels. Ray-casting through a grid is much faster than tree traversal, and this also enables us to store the 4x4x4 grids in texture memory, so this is superior both from a computational standpoint, and a memory-access standpoint.

The second main point of departure from other implementations is that I make no attempt to store normal vectors for the voxels. Instead, my plan (and I have a partial implementation of this, although it is not "hooked up" in the code provided below) is to use a MRF to infer normals from the depth buffer--this is documented (in detail) here.

The final result is reasonable as a "proof of principle" implementation, and the frame rates are acceptable at low resolutions, but it is neither as complete or as fast as I would like. Much (but not all) of the code is documented using Doxygen---you can find the documentation here.


The implementation is in C++/OpenCL. Most of the development and testing was done in parallel under Linux (using SDL) and Windows (using DirectX). In order to compile, you'll require the boost libraries, an OpenCL compiler, and the appropriate graphics libraries for your platform.

All source code is copyrighted, and licensed under the GPLv3.

Source code voxel_src.tgz (532K) (551K)
One of the reasons that these archives are so large is that they contain the images needed to generate the Doxygen documentation.