POV-Ray : Newsgroups : povray.text.tutorials : fast/reasonable menger sponge rendering Server Time
24 Nov 2024 00:13:11 EST (-0500)
  fast/reasonable menger sponge rendering (Message 1 to 2 of 2)  
From: ehmdjii
Subject: fast/reasonable menger sponge rendering
Date: 1 Dec 2003 19:30:30
Message: <Xns9445F57D7B5CehmdjiiNOSPAMgmxnet@204.213.191.226>
hello, 
im trying to render a menger sponge with this simple code:

#macro makemenger(d)
 #if (d=0)
  box{-1,1}
 #else
  #local i=0;
  union {
  #while (i<20)
   object { makemenger(d-1) translate posi[i]*2 scale 1/3}
   #local i=i+1;
  #end 
  }
 #end

which just places boxes in their position.
i can render a sponge at level 4 quite good, but at level 5 it starts to 
parse, but after 5 minutes the memory is full and i get an E/A error.

probably because its too many boxes.
so are there any tricks to use just one instance of the box in the 
memory?

any tips and hints are welcome! ;)

thanks!


Post a reply to this message

From: JC (Exether)
Subject: Re: fast/reasonable menger sponge rendering
Date: 5 Dec 2003 07:59:58
Message: <3fd0814e@news.povray.org>
At level 5, you seem to have 20^5 = 3200000 objects which is a lot.
When you want to save memory, it is usually a good idea to turn toward 
meshes because duplication of a mesh just uses the same object in memory 
which is not true for CSGs.

But I'm not sure it is going to be very efficient if you just replace 
your box with a mesh-box. It's still worth giving it a try. Another 
possibility is to generate or create a menger's mesh with, say one or 
two levels and then use it as a base object for a macro generated 
menger's sponge.

JC

ehmdjii wrote:
> hello, 
> im trying to render a menger sponge with this simple code:
> 
> #macro makemenger(d)
>  #if (d=0)
>   box{-1,1}
>  #else
>   #local i=0;
>   union {
>   #while (i<20)
>    object { makemenger(d-1) translate posi[i]*2 scale 1/3}
>    #local i=i+1;
>   #end 
>   }
>  #end
> 
> which just places boxes in their position.
> i can render a sponge at level 4 quite good, but at level 5 it starts to 
> parse, but after 5 minutes the memory is full and i get an E/A error.
> 
> probably because its too many boxes.
> so are there any tricks to use just one instance of the box in the 
> memory?
> 
> any tips and hints are welcome! ;)
> 
> thanks!


Post a reply to this message

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