POV-Ray : Newsgroups : povray.general : Rendering recursive objects (Menger Sponge) : Re: Rendering recursive objects (Menger Sponge) Server Time
29 Jul 2024 10:18:43 EDT (-0400)
  Re: Rendering recursive objects (Menger Sponge)  
From: clipka
Date: 9 Nov 2011 14:05:06
Message: <4ebacee2@news.povray.org>
Am 09.11.2011 07:14, schrieb Paul Fuller:

> For a Menger Sponge, each level of recursion increases the number of
> cubes by 20x. So by level 7 (if level 0 is 1 cube) you would be
> specifying 20^7 cubes or 1.28 billion cubes. Even though the cubes are
> simple, each one has to be located in 3D space and may even have
> associated texture info etc.
>
> Given the nature of ray tracing, each of these has to be in existence.
> Note that bounding boxes may not need each ray to be tested against each
> object but in any case they are represented as objects in memory.
>
> Even instancing a cube as a mesh will still result in 1.28 billion
> instances as I understand it.

Indeed; for such a sponge resolution, just the *index* of all the little 
cubelets would require 4.7 GB on a 32-Bit computer (which is alraedy 
more than such a machine can handle), or 9.5 GB on a 64-Bit computer. 
And that doesn't even include a single bit of data per cubelet.

Here's a helpful trick though: Suppose you /do/ build your sponge out of 
meshes instead of boxes - using multiple instances of one single mesh - 
then each cubelet still requires its own overhead, but the actual shape 
of the mesh instances is only stored once. And here's where the fun 
begins: It doesn't matter much how many triangles you use to define the 
cubelet. It doesn't actually need to be a cube at all; for instance, it 
might be interesting to see how a level 6 menger sponge built out of 
octahedra would look like. Or, just for the sake of it, built out of a 
cube with square holes punched through each face, like a level 1 menger 
sponge...

... Oh, wait... :-)


Fun fact: A simple level 4 menger sponge built out of level 4 menger 
sponge mesh instances will require far less memory than your current 
level 6 menger sponge built out of cubes (I'd expect a factor of roughly 
100).

Of course an isosurface solution would require virtually no memory at 
all in comparison, but the formula might be hard to devise, and possibly 
slow to render. Just saying.


(For the sake of completeness, instead of modeling a menger sponge as a 
compound of multiple smaller menger sponges you could also model it as a 
cube with square holes of various size punched through all faces at 
certain places, which would let you get away with less than 16 million 
boxes for a level 7 sponge. However, mind-bogglingly slow render times 
would be guaranteed, as POV-Ray doesn't cope well with CSG objects 
having lots of holes, so it's not a real option.)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.