POV-Ray : Newsgroups : povray.programming : [PATCH] use boundings for inside testing : [PATCH] use boundings for inside testing Server Time: 26 Sep 2017 21:49:47 GMT
  [PATCH] use boundings for inside testing  
From: Micha Riser
Date: 3 Aug 2002 11:43:27
First I show an example where what for the patch is good. Consider the 
menger fractal constructed as follows:

macro menger(l,d)
 #if (d>0) 
  #local p = menger(l/3,d-1) union{ 
  #declare ix=-1; #while(ix<2) 
   #declare iy=-1; #while(iy<2)
    #declare iz=-1; #while(iz<2) 
     #if ((ix!=0 & iy!=0) | (iy!=0 & iz!=0) | (ix!=0 & iz!=0))
      object{p translate <ix,iy,iz>*l/3}
     #end
    #declare iz=iz+1; #end
   #declare iy=iy+1; #end
  #declare ix=ix+1; #end bounded_by{box{-l/2,l/2}}}
 #else sphere{0,l/2} #end
#end

#declare myplane = plane{x,0 translate<-6,0,0> rotate <0,90,0> rotate 
<45,-20,0>}

intersection{
 object{menger(4,3) rotate <20,30,0> translate <0,0,10>}
 object{myplane} // *
 pigment{rgb 1}
}

light_source{<-100,200,-20>,1 }

This needs about 250s to render and the statistics say
Box                            1417965          164676     11.61
CSG Intersection                 82765           13615     16.45
CSG Union                       164676          131410     79.80
Plane                            82765           81320     98.25
Sphere                         1958320          105681      5.40
Bounding Object                1417965          164676     11.61

But if you remove the line markes with an '*' it only needs 2 seconds and 
gives: 
Box                            1422461          161254     11.34
CSG Intersection                 83741           17944     21.43
CSG Union                       161254          122553     76.00
Sphere                         1886360          100982      5.35
Bounding Object                1422461          161254     11.34

You see that the number of test are nearly the same. Why does it take so 
much longer then? Each time a ray hits the plane it tests if the 
intersection point is inside the menger fractal. But it seems to do this 
for *each single sphere*. 

My patch changes this. It first tests if the point is inside the bounding. 
If it is NOT then it knows that it can already decide that the point is 
outside (if the object IS NOT inversed) or that the point is inside (if the 
object IS inversed).

Therefore with my patch applied it needs only 2 seconds to render for *both 
cases*.

- Micha

-- 
http://objects.povworld.org - the POV-Ray Objects Collection


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

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