Tales From a Voxel World, part 2: First experiment with ray marching

In April 2018, I wrote the first Tales From a Voxel World dev log. But I never got around to really start my ray marching journey because of other projects (such as nine months of constant nausea followed by a new baby, an 8-year-old, studying, making a robot for a competition… the list is long 😉 ).

But early this summer I finally implemented my first voxel ray marching algorithm!

My very first ray marched voxels

This first version is based on the algorithm in the article “A Fast Voxel Traversal Algorithm for Ray Tracing” by John Amanatides and Andres Woo.

I was super proud of my very first ray marched voxels. But if you look close at the image above, the implementation was full of bugs.

So I went on a bug hunt!

First ray marched voxels with no bugs!

And hurray no more bugs. Now it was time to render something a bit more fun.

Like randomly placed voxels that form some sort of sphere.

So much fun! But also not optimized in any way and rendered using only the CPU, so it actually took a couple of seconds to render it on my MacBook Pro.

However, before I experiment further with optimizations, I also wanted to try out the algorithm on a simple noise generated terrain.

For this I used the libnoise library to generate a height map which was then used to populate a 3D array with voxel data.

My first ray marched voxel terrain

Wow. This was by far the coolest data to render with the algorithm so far. I also made another picture of the island from another camera position and angle.

Ray marched voxel terrain

I’m still debating which direction to go next.

I might start by optimizing the CPU algorithm and data structure, or I might start by moving the algorithm onto the GPU.

Either way this first dive into ray marching was really fun. And I will definitely experiment further with it later.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.