When Earth Is Like an Egg: 3D Terrain Visualization
Some of the most satisfying breakthroughs happen when technology gets used in a way it was never intended. Check out how open-source software StippleGen, which was originally intended for egg painting, was applied to 3D terrain modeling.
Join the DZone community and get the full member experience.Join For Free
some of the most satisfying breakthroughs happen when technology gets used in a way it was never intended . while working with our graphic design group at sasaki on ways to generate a dot pattern for a decorative screen, we came across some open-source software called stipplegen . stippling is a way of creating an image by means of dots. stipplegen was created to optimize stippling for, among other things, egg painting. the software does a great job of laying out dots with greater density on the darker areas of the image while keeping a comfortable spacing between the dots. what's more, the voronoi algorithm it uses gives an irregular, organic pattern. the ah-ha moment came when i realized this could be applied to a different problem, visualizing terrain; specifically, optimizing terrain meshes in 3d software based off of elevation data (a.k.a. digital elevation model (dem)).
here's a typical use of stipplegen:
used to create this:
(image from http://wiki.evilmadscientist.com/stipplegen )
so, how do we get from eggs to terrain? a given terrain, unlike an egg, is typically a mix of high variation areas, like canyons, with more uniform areas, like plains or plateaus. a typical dem heightmap can be seen in the following image (top left) alongside some more familiar, human-readable representations of the same terrain that you might see on maps. shaded relief is a useful trick for representing terrain in 2d where the terrain appears to be lit from one side.
while shaded relief is an effective way of representing terrain for maps (from directly above) it is insufficient for 3d representations like those you might find in cad software, virtual reality, or video games. the challenge with generating 3d mesh images from heightmaps is that the heightmaps typically contain significantly more information than you can capture in a 3d mesh without blowing up the polygon count and slowing down your frame rate to the point where smooth animation or manipulation in real-time becomes impossible even with high powered gpus. a variety of sophisticated algorithms exist for optimizing meshes, but they can be time-consuming and require specialized tools that are hard to generalize across multiple workflows.
what we realized was that we could use the open source stipplegen tool and modify it to take in both a heightmap as well as a variance map (an image using darker grays to represent those areas with the greatest variation in the heightmap). this crowded the dots in the areas of greatest variation resulting in more detail where we wanted it. we could also control the density and level of detail of the resulting mesh using a slider. what's more, the organic quality of the dot distribution also helped reduce the bias imposed by a regular grid where details could fall between the cracks.
the result is a tool that provides a highly optimized 3d mesh for use in everything from autodesk revit, 3d studio max, rhino, sketchup, unity, or webgl. all from a tool created for decorating eggs! a technological exaptation !
here's our terrain data in stipplegen using a variance map to concentrate the dots where we want them:
using stipplegen's layout, we converted it to a 3d terrain map in revit:
Published at DZone with permission of Ken Goulding. See the original article here.
Opinions expressed by DZone contributors are their own.