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

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:

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 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:

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:

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.

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:

*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.