2
\$\begingroup\$

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.

7 Days to Die screen capture: "3 aim crafted dirt block at the obstruction."

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ Can you add some screenshots to your question? Not everyone has played every game in existence. \$\endgroup\$ – Philipp Jul 23 at 22:12
  • 1
    \$\begingroup\$ See also How can someone make 3D tiles not looking like perfect cubes? \$\endgroup\$ – Theraot Jul 23 at 23:18
  • \$\begingroup\$ Screenshot added \$\endgroup\$ – user6329530 Jul 24 at 8:36
  • \$\begingroup\$ @Theraot Ive seen the Marching Cubes theorem but none of the 15 configurations result in the blocks 7dtd uses. \$\endgroup\$ – user6329530 Jul 24 at 8:42
  • \$\begingroup\$ 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. \$\endgroup\$ – trollingchar Jul 24 at 9:03
6
\$\begingroup\$

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.

Rhombicuboctahedron

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:

Three vertices set for Marching Cubes, one isolated vertex, two contiguous

Results in the following output:

A octahedron, plus an elongated square bipyramid (a.k.a pencil cube), which is a kind of irregular dodecahedron

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:

Marching Cubes configurations

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.

\$\endgroup\$
  • \$\begingroup\$ Thanks for explaination. However a small corretion: It's an octahedron, not a tetraedon. A tetraedon has 3 triangles an octahedron has 8 triangles ("double pyramid" like). \$\endgroup\$ – user6329530 Jul 24 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.