Content, images, and animation copyright © 1997–2026 Peter C. Miller.
At several points in my career, while testing 3D software and GPU hardware, I needed a polygonal model that could grow in density on demand. The Menger sponge fits that need: each iteration adds a predictable jump in complexity. I wrote several MEL and Python scripts for this, using different methods — subtractive booleans, additive construction, and simple replacement — to build sponges of different depths.
People who are technically familiar with 3D rendering software know that the efficient way to render a Menger sponge is a custom shader, not a pile of polygons. If the goal is frame rate optimization, the geometric approach below looks wasteful, especially from a memory-consumption standpoint. However, memory optimizing is not the goal here. I created these models specifically to stress workstations, graphics cards, and render engines of any kind — to empirically measure compute performance under increasing stress, and therein find the practical limits of the comprehensive results of the entire target system. For that, a linear, geometry-defined polygonal mesh Menger sponge works very well.
I did not want compute complexity for its own sake, though; I wanted a tight match between the visual result and the minimum data complexity required to render it. A casually built sponge often keeps hidden internal faces that unnecessarily tax both GPUs and software renderers. Unoptimized Menger sponges can also define redundant and duplicate vertices.
The snapshots below detail the challenges for both polygonal face and vertex optimizations.
Menger sponge level 1:
The same sponge in X-ray display:
Same sponge, with unneeded internal surfaces in orange:
A clean level-1 sponge with those faces removed. Only 24 surfaces come off at this level — not much, but the savings grow quickly:
Level 2 with duplicated internal surfaces: 2,400 faces.
Clean level 2: 1,056 faces.
Removing those faces adds up. At level 3 a clean sponge has 18,048 faces; a lazy one has 48,000. The scripts can build either, to any level Maya’s memory will hold. That ceiling is higher in 64-bit Maya. Clean builds take longer. Memory use is roughly 200–250 bytes per vertex.
“Clean” here also means watertight: no hidden faces, and every remaining face could be seen from outside if a camera could sit in the voids. Filled with water from the inside, these sponges would not leak. They have neither leftover internal surfaces nor duplicated vertices.
Unoptimized:
With Maya’s Poly Count display on, you can see the unoptimized mesh: 36,096 triangles. That is what the graphics engine has to draw. Though no vertices are duplicated, more exist than are needed to draw the true Menger surface. Compare that with the optimized version below.
Optimized:
Same level-3 sponge, but each level-1 cube has had unneeded vertices merged. Triangle count is now 27,648 — over 23% lower.
I have built clean sponges through level 6 in Maya. Level 6 and above really want a 64-bit session.
These scripts were useful for stress-testing software and
hardware at
Alias|Wavefront
(owner of
Maya
before
Autodesk),
at
DreamWorks Animation
(interactive display in Premo, and the
MoonRay renderer),
and on personal work, some of which is below.
Fun story: during render experimentation with MoonRay,
these Menger sponges revealed an initially unknown visual
artifact, which turned out to be a hard-coded limit of 10,000
associated with ray dispersion for transparent surfaces — a
limit some software engineers thought would never be practically
encountered in image rendering.
A simple animation of Menger sponges (Menger cubes) from level 0 through 5:
High-resolution OpenGL views of level 5:
Lower corner view:
Hardware display capture with Maya’s “Wireframe on Shaded” on. The openings are easy to count, from the largest holes down to level 5.
“Street view”:
This view sits slightly above the lowest level, looking up through the sponge as if it were a building. At that scale the form is a study in fractal architecture and hierarchical porosity — a different idea from the slender “pencil towers” that have multiplied in Manhattan and other financial districts. Those towers chase height and floor-plate efficiency on a tiny footprint, and they pay for it in wind response, stacked construction tolerances, and concentrated load. A Menger sponge building would distribute mass, punch volume full of voids, and repeat the same pattern at every scale.
At building scale, that porosity would cut dead load and still leave many paths for gravity, seismic, and wind forces. The openings would also let daylight and air deep into the volume, and make room for planted sky courts in the voids — closer to biophilic and passive-performance goals than a sealed glass shaft.
The most interesting architectural idea may be the voids themselves. Each iteration adds a continuous grid of corridors and shafts — a three-dimensional graph of routes baked into the structure. Those channels could be built as multi-directional transit: a city-scale movement system that is also the building. Ropeless elevator systems such as TK Elevator’s MULTI (formerly ThyssenKrupp) already show cabins that can travel vertically, horizontally, and on loops in shared shafts, driven by linear motors or maglev.
A Menger lattice would supply those shafts at several scales: large atria and cross-tunnels at the early iterations for high-capacity loops, and finer channels at later iterations for smaller or autonomous cabs. Riders could take direct paths through the matrix instead of the usual up-then-across bottleneck. Extra routes would help with safety; traffic software could balance flow across the whole network. That is point-to-point movement in three dimensions — an old goal in visionary urbanism and arcology schemes.
The look would split people immediately. The raw recursive geometry reads as science-fiction megastructure, but that honesty of construction also leaves room for façade work: glazing, perforated metal, precast, or adaptive solar skins on the smallest cubes, changing light, shadow, and heat while keeping the self-similar pattern visible at every scale. The porosity would be the architecture — a building that is both massive and open, monumental and finely divided.
An early concept piece: sponges multiply into the next depth instead of subdividing. From a standing person’s point of view, a one-inch level-0 cube grows into a 1,640-foot level-9 sponge.
Levels above 4 were faked with procedural texturing so the shot would fit in 32-bit memory. The idea owes something to the old Powers of Ten films. I still plan a second version with scale references — basketballs, chairs, cars, boats, 747s — so the size is easier to read. Built in Maya, with MEL driving the animation.
A short film of Menger sponges on a lonely planet, pushing scale until it turns unsettling:
Content, images, and animation copyright © 1997–2026 Peter C. Miller.
More recent Menger sponge renderings with open-source MoonRay, on LinkedIn.