An algorithm for smoothing voxel terrain

Kristian Kristola

Kristian Kristola

· 5 min read
flutter

Photo by Gabriele Domicolo on Unsplash

 

Voxel terrain is a popular way to represent 3D geometry in games and simulations. However, voxel terrain can look blocky and unrealistic. In this post, I will describe an algorithm for smoothing voxel terrain to make it look more organic and less blocky.

This post doesn't describe how to generate or store voxels, but rather how to convert them into a mesh and then smooth the geometry.

 

Step 1: Convert voxels to mesh

Once you have your voxels in some data structure, you can convert them into a mesh. This can be done by iterating through all the voxels and adding a quad for each boundary between two voxels whenever on one side of the boundary there is air and on the other side there is solid material.

The result could look like this:

alt text

 

Step 2: Smooth the geometry

To smooth the geometry, you can use a simple algorithm that iterates through all the vertices, and moves each one of them towards the average of their neighbors. This will make the geometry look more organic and less blocky.

You could fine-tune the algorithm by taking a weighted average of the original vertex position and the average of the neighbors, and by adjusting the weights so that the smoothing looks good with your particular geometry.

alt text

 

Step 3: Apply Catmull-Clark subdivision

Finally, to further smooth the geometry, we can apply a subdivision algorithm such as Catmull-Clark. This algorithm will subdivide each face into smaller faces, and move the vertices towards the average of their neighbors. This will make the geometry even smoother and more organic.

alt text

Kristian Kristola

About Kristian Kristola

I'm a consultant and software developer with a strong foundation in game programming and the ability to adapt to new technologies and languages. Please feel free to contact me at:@
Copyright © 2024 Kiuas Games. All rights reserved.
Made by Osuuskunta Kiuas Games

This website uses Google Analytics to collect anonymous information such as the number of visitors to different pages.