An implementation of a procedural DSO is
given below, menger.c, along with a Makefile
and RIB file, menger.rib, to assemble and test the DSO. Refer to
download below.
Because of the subdivision scheme used by the DSO, rather large menger structures can be created with a small memory foot print. Two major factors contribute to the small memory foot print: i) the geometry occludes rather quickly so some bounded boxes representing geometry that is never seen is not expanded, ii) the subdivision creates bounding boxes that center around the bucket that PRMan is currently rendering so only the geometry that needs to be diced is expanded and the rest are represented by low memory using bounding boxes.
When rendering a level 6 menger structure, on average 18,000 DSO primitives exist at a time with a maximum at 39,000 when rendering a side at grazing angles. (Refer to menger6.jpeg for an example rendering of level 6 Menger sponge.) Some of these DSO primitives represent many thousands of cubes in the menger structure while others represent a single cube as 6 bilinear RiPatch primitives ready for rendering. More optimizations could be done, for example, if the camera's point of view were given, the cubes could be reduced from 6 to 3 RiPatches since 3 of the patches are always covered by the 3 forward facing patches. Also some surface shader techniques could be added in so at low levels of detail an estimate of the nth level surface could be rendered. At present the code mostly relies on PRMan to expand the geometry in an optimal manner, but it still serves as a nice DSO example.
At level 17, the menger DSO has (20^17 cubes) * (288 bytes/cube) = 3.12 YottaBytes of potential RiPatch data. For those not familiar with a YottaByte, the order of names is kilo (2^10), mega (2^20), giga (2^30), tera (2^40), peta (2^50), exa (2^60), zetta (2^70), and yotta (2^80). A yottabyte can also mean 10^24, but in relative terms it is still pretty close to 2^80 which is 1.209e24. To distinguish the base 2 from the base 10, the standard boards might call 2^80 a YobiByte someday -- but whether Yotta or Yobi they both oddly sound like names of Star Wars characters. For those who use YottaBytes all the time, a more casual looking ybis probably used. For example, a level 17 menger structure would be a mere 3.1yb.
There does not appear to be a name yet for the 2^90 size, but since folks are thinking of doing yotta there might be a name sometime soon.
Please don't take the above too seriously. Although accurate information, I was just having a bit of fun.
Four files are needed to build and test menger.so:
menger.c Makefile config.mak.sun menger.rib