Voxel Raycaster: Enter the Stanford zoo

If you’ve looked at some computer graphics literature before, you’ve probably noticed that a lot of models are used over and over again, like the Utah Teapot. Last days, I’ve been working on import functions which allow me to load the Stanford standard benchmark models in and render them, voxelized.

Problem is of course, that most of these models are only offered in triangular mesh form (.ply, .obj files). Also, there’s no real standard for saving volume data. I wanted to avoid coming up with yet another filetype myself, so I ended up using binvox, an excellent tool from Eric Haines, which can convert triangular meshes to binary voxel files (with a small ASCII header). The tool is pretty popular in the Minecraft community, because it allows players to use meshes built from minecraft materials. (You didn’t think this lunatic made that manually, did you?)

Reading the binary voxel data was easy, converting them to my internal data structures wasn’t – spent a lot of time wrestling with Boost’s Multi-Array library (excellent tips and remarks here) – turns out I bumped into a bug which only manifests itself in Debug mode.

Anyhow, here are some renders of well-known animals. I’m going to look into a way to estimate voxel normals in the mesh->data grid process, because without normals, there’s no way to do any correct shading, and a lot of model features (creases,…) get lost.

All of the following pictures were rendered at a 600×600 resolution. All generation times were < 1000 ms, which I think is pretty good for a software-mode only renderer – no hierarchy in voxel trees as well. After I’ve looked into ways of stacking more data into the voxel data points, I’ll probably look at a GPU ray casting implementation.

(Click each image for large version.)

128x128x128 voxel grid - and an error in the color generation :)

Attempt at shading, all normals pointed forwards. Need real normals.

32x32x32 data grid - even at a low grid resolution, general shape is still good

Armadillo says booh (256x256x256 grid)

Sparsely rendered Stanford Dragon (128x128x128 grid resolution)

Sparsely rendered Stanford dragon, only grayscale (256x256x256 grid)