Marching Squares Skirts

When two chunks of different detail are next to each other, cracks will appear:

1: Cracks within the volume terrain

To remedy this problem, the concept of “Marching Squares Skirts” is introduced. With this, the holes between the chunks are closed with some additional triangles. This has the advantage, that the chunks are still completly independent and later, things like paging are easier.

At the borders of each chunk, triangles are generated closing the partial volume mesh covered by the chunk. This closing is just at the borders, or else, unneeded triangles would be produced. That’s why it’s called “skirts”. Here are the skirts of a chunk in a sphere volume:

2: Marching Squares Skirts of a sphere chunk

2: Marching Squares Skirts of a sphere chunk

To build this skirts, Marching Squares is used. Marching Squares is the two dimensional case of Marching Cubes. Lingrad et al show how this algorithm works with its 2^4 = 16 possible configurations by creating the isosurface of a 2D volume consisting of lines [LCGR02].

The concept has been adjusted to fit to this project. Instead of lines, triangles are generated. Here are the 16 possible cases with the created polygons in gray:

3: The 16 possible configurations of Marching Squares

3: The 16 possible configurations of Marching Squares

The skirts are build at the corners of the outer dual cells of the chunks dualgrid (see Dual Marching Cubes). As in Marching Cubes, the diagonal configurations have multiple valid triangulations. But the configurations in figure 3 are chosen in a way that they always fit to the used Marching Cubes configurations and no conflict appears.

The normals are calculated just like in Marching Cubes. But they don’t get a length of one. In order to make the skirts as unobstrusive as possible in the texturing, they get a length of their isovalue. This information then is used in the triplanar texturing shader to get a small offset to the planar projections and so no stretching appears. The according formulas of the triplanar texturing are slightly altered for this:

texCoord_{yz} = \left(\begin{pmatrix} p_y \\ p_z\end{pmatrix} + |\vec{N}| \right) \cdot scale
texCoord_{xz} = \left(\begin{pmatrix} p_x \\ p_z\end{pmatrix} + |\vec{N}| \right) \cdot scale
texCoord_{xy} = \left(\begin{pmatrix} p_x \\ p_y \end{pmatrix} + |\vec{N}| \right) \cdot scale

Have a look at figure 4 for the result of this tweak. The left side doesn’t have it, on the right it is applied.

4: A small tweak in the triplanar texturing to hide the Marching Squares Skirts

4: A small tweak in the triplanar texturing to hide the Marching Squares Skirts

There are two optimizations done when generating the Marching Squares Skirts. First, the outermost chunks of the volume don’t get them as there never will be two chunks together and so there will be never cracks. And second, for the last configuration where all four corners are inside the volume, only triangles are generated which are near enough to the surface. This formula is used for the calculation:

minimumDistance = level \cdot errorMultiplicator \cdot baseError \cdot skirtFactor

level, errorMultiplicator and  baseError will be explained later when building up the chunktree. skirtFactor is a user choosen factor to add some more control. The smaller it is, the less triangles are generated. But if it is too small, cracks might appear.


If you like this work and want to support it, feel free to donate something or click on any Flattr button!