As seen, Marching Cubes has the big disadvantage of creating a lot of triangles even in flat areas where they are not needed.
We solve this problem by switching to the more complicated, but superior algorithm Dual Marching Cubes by Schaefer and Warren [SW04]. The full blown version of it fixes also some more issues of Marching Cubes like not being able to produce sharp edges and missing thin features, but as terrain is something organic without those characteristics, a more basic version is shown here.
The algorithm is split into multiple sub articles, as the content would be too much for a single one. The first one is about creating an octree from the density source, the second one about deriving a data structure called dualgrid from the octree, and finally, triangles are created off the dualgrid.