# How can I smooth my voxels similar to 7 Days to Die?

7 Days to Die is a voxel space game like Minecraft. However unlike Minecraft, the ground blocks, sand, ore and stone are smoothed so they blend into each other and hills and tunnels appear more rolling and smooth than the blocky Minecraft style.

When you create one of these blocks, you get an octahedron shape object but when you place it, it fills in a smoothed area covering a whole block.

I want to implement something like this in my Unity game. What kind of algorithm can I use to smooth out my blocks, making them blend into each other?

Since I can't start the game right now, I add a screenshot from steamcommunity which shows the block boundaries with the "smoothed" (highlighted) dirt block inside. When the dirt/sand/gravel/ore block falls, it looks the same just not glowing.

The screenshot also shows that the surrounding blocks on that trench wall are forming a slope not a clean edge; They are blended into each other.

• Can you add some screenshots to your question? Not everyone has played every game in existence. Jul 23, 2019 at 22:12
• Jul 23, 2019 at 23:18
• Screenshot added Jul 24, 2019 at 8:36
• @Theraot Ive seen the Marching Cubes theorem but none of the 15 configurations result in the blocks 7dtd uses. Jul 24, 2019 at 8:42
• These 15 configurations don't correspond to in-game block, but rather to a space between centers of 8 blocks. If you have one block hanging in the air, the algorith will render 8 triangles in shape of an octahedron. So it does look like it's marching cubes. Jul 24, 2019 at 9:03

## It is not simply Marching Cubes

With marching cubes, a block would expand into the surrounding ones. In fact, with the default configurations for the Marching Cubes algorithm the result is a Rhombicuboctahedron, depicted below.

That is the result of considering all the eight vertices of a cubic block set as input for the marching cubes algorithm.

## It is Marching Cubes

Wait, what?

We do not need to set cubes and see what vertices are covered or exposed. Instead, we can set vertices directly.

See the video marching cubes algorithm for a demonstration. Notice that the set of vertices used as input for the marching cube algorithm do not form cubes. It is instead just three vertices (one isolated, two contiguous).

The linked video shows how the following input:

Results in the following output:

As you can see we end up with a octahedron (similar to the one shown in the question) which comes from the isolated vertex. Plus an elongated square bipyramid that comes which comes from the two contiguous vertices.

See the 15 configurations from the original Marching Cubes paper:

The tetrahedron is formed by the second configuration of the 15 shown above (the one with a single highlighted vertex), being applied on the eight cubes that surround the isolated vertex.

## The other algorithms

I want to bring attention to the fact that Marching Cubes is not the only solution. There is also Marching Octahedra and Marching Tetrahedra. Sadly information on these is less abundant.

function Smooth(solid,air) {
return Mathf.Lerp(1.0-(solid-surface)/(1.0-surface),1.0-air/surface,(solid-surface)/(solid-air));
}


solid and air are points weights, surface is the minimum weight to become ground, this is my way to generate vertices in voxel edges

example: v=Vector3.Lerp(a,b,Smooth(aWeight,bWeight));

https://estantaya.itch.io/elsa-simulator

7 days to die uses custom Marching Cubes implementation. With some smoothing applied, and a floating point density cloud with vertex offsets. I have almost the same algorithm implemented manually, and will release it on Github someday, the project is named TileVox.