Content, images, & animation copyright © 1997-2026 Peter C. Miller.
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:
The same Menger Sponge in X-ray display:
Same sponge, with unneeded internal surfaces displayed in orange:
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:
Same again - only this time a level 2 with unnecessary duped surfaces,
with 2,400 faces total:
And a "clean" Menger Sponge of level 2 as well, consisting of a more
tidy 1,056 faces:
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:
Content, images, & animation copyright © 1997-2026 Peter C. Miller.
Some Hi Res OGL Renderings of Level 5
The above image is a hardware display capture with Maya's "Display Edges" turned on. It's cool to clearly see and count the open holes that are present from the largest to the smallest down to level 5.
This image above has the camera a little bit above the lowest level, aiming up, as if the Menger Cube was a building. It's interesting to think of it as giant office or residential structure. In the field of architecture, this could be considered an extreme opposite of the "Pencil Towers" now in Manhattan and other metropolitan areas. Personally, I find these Pencil Towers to be more of a monument to "attraction to design" than "safety where I sleep". I'd love to go to a party in a Pencil Tower, but I'd not want to live in one. For me, there would be too much likelihood of unplanned wind storms or construction imperfections suddenly resulting in catastrophic collapse, which would be an excellent mental stimulant to prevent sleep.
A building in this form of a Menger Cube would be about as stable as one could have for any volume. (Well actually, no, a Sierpinski tetrahedron would be, but that wouldn't be very conducive to elevators or architecture people could live in.) Also the definition of open space would intrinsically keep the weight stress down as well. I would sleep very soundly in a Menger Cube building, knowing it would never blow over, or collapse from its own weight.
There would also always be an open air space patio nearby. The central ones would be huge.
Aesthetically, a building of this shape would stimulate reactions - "That looks like a horrible building of the evil Borg!", I can imagine an architectural critic saying. And they'd be right. But I bet some interesting interleaving of glass and concrete patterns of each smallest cube section could make it visually more interesting than just the strict shape of the cubing.
On the spectrum of Form to Function / Art to Engineering, a Menger Cube building would be about as hard right on the spectrum as one could get, especially compared to Pencil Towers.
Animation #1: "Miller's Menger Sponge"
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"
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.