Samstag, 6. August 2011

Rendering Sparse Voxel Octrees

In just a few years of time, Sparse Voxel Octrees (SVO's) will be a state of the art technique. Right now, we're at very early stages, with Minecraft providing us with in-game editable voxels at the scale of 1 meter edge length per block.

After I spent another few days on Minecraft servers, exploring the possibilities of the game and the various modifications that its fans have made, I saw that there is a strong wish for a more expressive resolution. On servers like The Voxel Box, artists keep pushing the envelope, using the ambiguity of block designs to repurpose each design for various meanings, e.g. fences are also wooden support structures or lamp posts, and signs are also used as arm rests for couches.

I would like to go further, and get my engine down to 1/16th of the resolution, allowing artists to edit the world at 1/16th of the scale, which is about ~6cm edge length.

Already, Minecraft has troubles managing its data mass, but I'm hoping it's merely inefficiently coded, I know, for instance, that the hierarchy it uses is not entirely octree balanced. Surely, with better distribution and a slim SVO data structure, those troubles might become more manageable.

I know that the data mass might eventually become too large, and needs to be saved to disk - but for simplicity, I'll start with keeping everything in memory.

After talking to a good friend, who is deep into raytracing and cutting edge CUDA/OpenCL computing, I tried a raymarching approach on the CPU first: The renderer casts an individual ray per pixel, which is collided against the octree recursively until a voxel has been found.

The approach isn't fast on a single core, but I might be luckier with the same process running on the GPU using OpenCL. My GeForce 8800 GTS 512 (G92) is perfectly capable of doing generic purpose calculations, so I can bypass all the OpenGL shader madness and port the code directly.

Another important job lies in producing content. Like Minecraft, I will most likely use a combination of generated landscapes and hand edited content. The landscapes will most likely be based on 3D perlin noise functions, controlling density, and later on, temperature and humidity, which can be translated into biomes.

For hand editing, I want a "Deluxe Paint" toolset for voxels, which means standard brushes of various sizes, copy/pasteable brushes, mirror/smoothing effects, palettes and so on.

Today I ported my codebase from my own small linear algebra library to GLM, a GLSL-style vector library for C++. The transition went smoothly.

The next step is now porting the raymarcher to OpenCL.

1 Kommentar:

  1. Your article contain lots of valuable stuff which is beneficial for me. If you are looking for Cheap Minecraft Server Hosting for your online gaming, then visit BisectHosting.