Saturday, November 13, 2010

I see a Voxel in your future

So I was looking for a good way to represent a 3D virtual world. Most virtual worlds, like the ones in massively multiplayer games, or even traditional game level scenes, are built using textured triangles. It is a simple and quick way to get very good results. This has been the method of choice since the early days of real-time rendering, graphics hardware has evolved so the entire work can now be done on the graphics card.

Content creation tools also evolved around the idea of textured polygons. There are very mature tools that will let you control the position of each vertex in your model, and the color of ever single pixel.

For my project I wanted to bypass the artist. None of the existing tools made much sense in my case. The expanse of terrain was so large, it would take many man/years to create by hand. If my project required a high degree of proceduralism, why then not go entirely procedural?

For this reason I chose to use voxels to represent everything in my virtual world. If this word is new to you, you can figure it out by extending the concept of a pixel. A pixel is one tiny dot in your screen, or in one image. Any image you can say it is composed of a two dimensional table, each cell of the table is a pixel that describes what color the image is at that location.

A voxel is a similiar concept, but in 3D. If you  think about it, voxels are a much more natural way to represent things in 3D than textured triangles. You may argue that the entire world is a big three-dimensional matrix, each cell of the matrix is a voxel that describes what type of element or material is there: air, water, wood, gravel, etc.

The problem with voxels is that you need way too many of  them to get results comparable to textured triangles. Also, the video hardware has evolved in a way that does not favor voxels. For that reason I chose to have an hybrid approach: Use voxels to create the world, but then translate the voxels into textured triangles so they can be quickly rendered in average systems.

The following picture shows this concept:


The first section shows the voxel. As you can see it looks like a series of stacked boxes. Each box is a voxel. The next section shows a triangle mesh. This mesh is obtained from the voxel. It is comparable to what an artist would have created using polygon modeling tools. The last section shows the same mesh, now textured.

At this point my task seemed pretty clear. I just needed to generate the world as voxels and then create the algorithms to translate those voxels into traditional textured triangles.

It may sound simple, but it was not. In the next post I will describe my first failed attempt.

No comments:

Post a Comment