POV-Ray : Newsgroups : povray.general : Speeding up rendering many spheres : Re: Speeding up rendering many spheres Server Time
26 Apr 2024 09:08:48 EDT (-0400)
  Re: Speeding up rendering many spheres  
From: Alain Martel
Date: 6 May 2020 15:02:41
Message: <5eb309d1$1@news.povray.org>
Le 2020-05-06 à 14:44, Nicolas George a écrit :
> Nicolas George, dans le message <5eb2fc87$1@news.povray.org>, a écrit :
>> I shall test, but it would be helpful to know what is supposed to be the
>> result.
> 
> I ran the test, with the scene below.
> 
> My conclusion is that POV-Ray does not try to compute bounding boxes for
> components of a CSG object.
> 
> Can somebody confirm it is the expected behavior?
> 
> Well, that means I should gain a significant speed improvement by computing
> intermediate bounding boxes before rendering.
> 
> As a side note: maybe a directive auto_bounding_box would be a good idea to
> let the scene author hint POV-Ray: "this is a very complex CSG object, but
> this part is small, it deserves its own bounding box".
> 
> Thanks for your help.
> 
> 
> My test scene:
> 
> camera {
>    location <0, 0, -2>
>    look_at <0, 0, 0>
> }
> 
> #macro many_spheres(x0, y0, z0)
>    #local i = -10;
>    #while (i <= 10)
>      #local j = -10;
>      #while (j <= 10)
>        #local k = -10;
>        #while (k <= 10)
>          sphere { <x0 + 0.001 * i, y0 + 0.001 * j, z0 + 0.001 * k>, 0.0008 }
>          #local k = k + 1;
>        #end
>        #local j = j + 1;
>      #end
>      #local i = i + 1;
>    #end
> #end
>      
> merge {
>    //merge {
>      many_spheres(-0.5, 0.5, 0)
>      //bounded_by { box { <-0.52, 0.48, -0.02>, <-0.48, 0.52, 0.02> } }
>    //}
>    //merge {
>      many_spheres(0.5, -0.5, 0)
>      //bounded_by { box { <0.48, -0.52, -0.02>, <0.52, -0.48, 0.02> } }
>    //}
>    pigment { rgb <1, 1, 0> }
>    finish { ambient 1 }
> }
> 
> // with bounded_by:  using 8 thread(s) with 3.698 CPU-seconds total
> // without:          using 8 thread(s) with 137.005 CPU-seconds total
> // without submerge: using 8 thread(s) with 136.182 CPU-seconds total
> 

In this sample, you have pigment{rgb<1,1,0>}
This have zero transparency. Meaning that you should absolutely use an 
union and not a merge.

It becomes :

union{
     many_spheres(-0.5, 0.5, 0)
     many_spheres(0.5, -0.5, 0)
   pigment { rgb <1, 1, 0> }
   finish { ambient 1 }
}


Post a reply to this message

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