Apr 272012
 

This series of posts is targeted to all of you aspiring voxel engine creators, as I will be explaining how my voxel engine (and countless others) work!

For this post, I’ll be talking about rendering a high load of cubes/blocks without all the processing power.

The most obvious method is just to store the cubes and then render each, but this wastes a lot of vertices, what if you can’t see a face of a block?

For example, a engine which does not use this this technology, known as face occlusion culling,  might render five blocks in a row as the following:

|_||_||_||_||_|

See all the wasted faces/vertices?

This engine would run for a low amount of cubes, but once you start creating worlds composed of these cubes, the engine will come to a grinding halt.
Now, let’s say you cull occluding faces.

Now, you’ll get something like

|_____|

We just saved 8 faces, and 32 (8×4) vertices!  That might not seem like a lot, but once you’re creating vivid and enormous landscapes, this really helps.

So, how do we implement this technique?

It’s really quite simple.

Before you process, draw, or create the vertices of a block, you want to make sure that the face that you’re creating vertices for isn’t occluding with another block.

This means that you should check for a neighboring block, and if there is one, not draw the face.

Pseudo-code:

if ( westBlock doesn’t exist ) createface(west);
if ( eastBlock doesn’t exist ) createface(east);
if ( northBlock doesn’t exist ) createface(north);
if ( southBlock doesn’t exist ) createface(south);
if ( topBlock doesn’t exist ) createface(top);
if ( bottomBlock doesn’t exist ) createface(bottom);

See how easy it is? :)

  One Response to “All About Voxel Engines – Part 1”

  1. Hi,

    What are you making the BloxEngine with? XNA? Direct3D? OpenGL?

    I am making one with Direct3D and C++.

    I noticed you said we saved 32 (8×4) vertices. With my game, I have to use 6 vertices per face(make 2 traingles)… how do you make a square with 4 vertices with D3D? Is it possible?

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>