thin blue line

Welcome to a World of Menger Sponges

Content, images, & animation copyright © 1997-2024 Peter C. Miller.

menger icon


Optimized Menger Sponge generation for 3d graphics:

At several points in my career, while testing 3d software and GPU hardware, I needed a basic polygonal model set which could easily grow in graphic content data density. The Menger Sponge fit the specification perfectly since each iteration allows for an arbitrarily defined level of complexity. I wrote several mel and Python scripts, each using different approaches to create Menger Sponges of different depths. Some are subtractive boolean in their approach, some are simply additive, some use basic replacement.

For those readers familiar with 3d technology, obviously the efficient way to go about rendering a Menger Sponge is via a custom shader, not with actual polygonal geometry. So to those interested in pure rendering fps rates and practical optimizations, the geometric approach described below may seem quite unnecessary or even counter productive. So I clarify here that my target realm is not efficiency, but testing and verifying the power of workstations, and in particular the capabilities of graphics cards. If "stressing the system to find the practical limits" is the goal, then this linearly-driven, geometry-based approach is (and has been) quite effective.

That said, I did not want inefficiency for inefficiencies sake. One problem I specifically wanted to address was that a casually formed Menger Sponge can commonly have unnecessary internal surfaces defined, which can seriously over-tax the target rendering engine, be that a graphics card or a software renderer. I also wanted to avoid duplicated polygonal vertices, which happily most 3d applications have efficient tools for removing.

The snapshots below describe this problem.

Menger Sponge level 1:

menger 1 simple

The same Menger Sponge in X-ray display:

clean menger



Same sponge, with unneeded internal surfaces displayed in orange:


simple menger xray



And a clean Menger Sponge, with no unneeded surfaces. In the example below, only 24 surfaces were removed, not much improvement... but that doesn't last long:

simple menger xray highlighted


Same again - only this time a level 2 with unnecessary duped surfaces, with 2,400 faces total:

simple menger 2 xray


And a "clean" Menger Sponge of level 2 as well, consisting of a more tidy 1,056 faces:

clean menger 2

You can see the removal of unnecessary surfaces can add up. And this is only level 2; for a level 3 there are 18,048 faces if it is built clean, while a 'lazy' level 3 Menger Sponge will have 48,000 faces. My scripts can build clean or lazy to any arbitrary level, with a maximum ceiling being of the amount of memory Maya consumes for the geometry data. Clearly this maximum level is higher if the scripts are run with the more recent 64 bit versions of Maya. Obviously as well building clean takes a bit more processing time.

Another point of clarification - these "clean" Menger Sponges are "pure" in the sense that no surfaces exist that are hidden, and every surface that exists is necessary and could be viewed from "outside" the sponge if a camera could be placed appropriately within the sponge. In other words, these clean/pure Menger Sponges could be filled with water from the inside, they would not leak.

So these Menger Sponges have neither unnecessary internal surfaces or duplicated vertices. So far I've used these scripts to make clean Menger Sponges level 1-6 in Maya. Keep in mind a level 6+ Menger Sponge really needs 64 bit memory space in Maya. (Memory consumption is ~200-250 bytes per vertex)

My Menger Sponge generation scripts were helpful for stress testing both software and hardware at Alias|wavefront (Owner of Maya before Autodesk), DreamWorks Animation), (for their 'Premo' animation tool's interactive display and 'Moonray' renderer,) and some personal projects, some of which are shown below.

Here's a simple animation of Menger Sponges (Menger Cubes) level 0-5:

anim menger

© Content, images, & animation copyright 1997-2022 Peter C. Miller.

Some Hi Res OGL Renderings of Level 5:



Animation #1: "Miller's Menger Sponge"

menger timeline

© Content, images, & animation copyright 1997-2006 Peter C. Miller.

This above movie is an old concept rough animation of mine which depicts a series of Menger Sponges multiplying into each iteration of Menger Sponge depth rather than subdividing. To see the animation, click here or on the image above.

In the animation we watch, from the point of view of a person standing, a Menger Sponge growing from a 1 inch cube at level 0 to a 1,640 foot tall Menger Sponge at level 9.

This was achieved in a 32 bit memory space by simulating levels above level 4 with procedural texturing. This animation was inspired partially from the old "power of 10" movies. I plan to have a second version of this animation with object scale references (basketballs, chairs, cars, boats, 747's etc.) added to aid a sense of scale. This animation was made with Maya and several mel scripts driving the animation procedurally.





Animation #2: "Planet Menger"

planet menger



Here is a short movie of Menger Sponges floating on a lonely planet filled with terrifying scale conceptualizations:

© Content, images, & animation copyright 1997-2006 Peter C. Miller.



planet menger

H O M E