POV-Ray : Newsgroups : povray.unofficial.patches : [PATCH] use boundings for inside testing Server Time
31 Oct 2024 23:32:44 EDT (-0400)
  [PATCH] use boundings for inside testing (Message 1 to 2 of 2)  
From: Micha Riser
Subject: [PATCH] use boundings for inside testing
Date: 3 Aug 2002 07:43:27
Message: <3d4bc1de@news.povray.org>
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)

From: Micha Riser
Subject: Re: [PATCH] use boundings for inside testing
Date: 4 Aug 2002 06:51:37
Message: <3d4d0739@news.povray.org>
Addendum:

The patch tests only additional boundings, that is only when 'bounded_by' 
is used. So the effect on everyday-scenes will likely be small. It could be 
extended to test the automatic-generated BoundingBox as well. But 
unfortunately POV-Ray does not generate a boundingbox-hirarchy with 
merge/intersections.. I do not really see why. 

- Micha

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


Post a reply to this message

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