POV-Ray : Newsgroups : povray.general : Slow CSG Server Time
7 Aug 2024 15:15:02 EDT (-0400)
  Slow CSG (Message 1 to 6 of 6)  
From: Arnold the Aardvark
Subject: Slow CSG
Date: 13 Sep 2001 11:46:20
Message: <3ba0d4cc$1@news.povray.org>
I created a shape by using the difference between a torus
and a union of many cylinders. This renders very slowly.
If I render the union of cylinders as the object it is much,
much faster. I am using bound_by.

Are there any other optimisations I can use for the difference?

Thanks.


Arnold the Aardvark


Post a reply to this message

From: Chris Jeppesen
Subject: Re: Slow CSG
Date: 13 Sep 2001 14:21:06
Message: <3ba0f912@news.povray.org>
Turn off the "eliminate maunal bounding" option (-ur). POV always thinks it
can bound better than you can, but it is frequently wrong when trying to
bound a difference.

turn on the display of bounding boxes (+ud) and see if huge areas of the
screen are in the bounding box of a small object

"Arnold the Aardvark" <aar### [at] NOTTHIStubulidentatademoncouk> wrote in
message news:3ba0d4cc$1@news.povray.org...
> I created a shape by using the difference between a torus
> and a union of many cylinders. This renders very slowly.
> If I render the union of cylinders as the object it is much,
> much faster. I am using bound_by.
>
> Are there any other optimisations I can use for the difference?
>
> Thanks.
>
>
> Arnold the Aardvark
>
>


Post a reply to this message

From: Mike Williams
Subject: Re: Slow CSG
Date: 13 Sep 2001 16:28:23
Message: <Uj4+1HAGZRo7Ewlc@econym.demon.co.uk>
Wasn't it Arnold the Aardvark who wrote:
>I created a shape by using the difference between a torus
>and a union of many cylinders. This renders very slowly.
>If I render the union of cylinders as the object it is much,
>much faster. I am using bound_by.
>
>Are there any other optimisations I can use for the difference?

What happens is that when you do the union, POV can put a tight bounding
box around each cylinder, so for each ray it only has to perform
cylinder tests for the few cylinders that that particular ray comes
close to.

When you do a difference, POV can't use the bounding boxes in the same
way. For each ray it ends up performing cylinder tests for every single
cylinder. You can see the effects of this if you look at the stats in
the message window. You'll find that there are a *huge* number of
cylinder tests, of which only a very small percentage were successful.
Whereas the union has about the same number of successful tests but a
much lower number of unsuccessful ones.

I did a scene a while ago with hundreds of small cylindrical holes in a
flat slab (rather than a torus) and experimented with cutting the slab
into smaller pieces with just a few holes in each piece. It turned out
that the rendering was fastest when each piece was so small that it
contained only one hole.

The following one large slab took 62 times as long to render as 400
pieces with one hole in each.

#declare N = 20;   
// One large slab with N*N holes
#declare Slab1 = difference
 {                         
 box {<-0.5,-0.5,-0.5>,<N-0.5,N-0.5,0.5>}       
 #declare xx = 0;
 #while (xx < N)
   #declare yy = 0;
   #while (yy < N)
        cylinder {<xx,yy,-1>,<xx,yy,1>,0.3}
     #declare yy = yy+1;
   #end
   #declare xx=xx+1;
 #end
 }



// Declare a small box with one hole
#declare Box = difference
 {
 box {<-0.5,-0.5,-0.5>,<0.5,0.5,0.5>}                    
 cylinder {<0,0,-1>,<0,0,1>,0.3}
 }
// Glue together N*N boxes into one slab
// so it looks like one slab with N*N holes
#declare Slab = union {               
#declare xx=0;
#while (xx < N)
  #declare yy = 0;
  #while (yy < N)
    object {Box translate <xx,yy,0>}
    #declare yy = yy + 1;
  #end
  #declare xx=xx+1;
  #end
}


The one-large-slab version made over 70 million cylinder tests of which
0.4% were successful. The 400-small-pieces version made 27 thousand
cylinder tests of which 31% were successful. 

The resulting images are identical.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Anoop
Subject: Re: Slow CSG
Date: 14 Sep 2001 09:21:58
Message: <3ba20476@news.povray.org>
Mike Williams wrote in message ...
>What happens is that when you do the union, POV can put a tight
bounding
>box around each cylinder, so for each ray it only has to perform
>cylinder tests for the few cylinders that that particular ray comes
>close to.
>
>When you do a difference, POV can't use the bounding boxes in the
same
>way. For each ray it ends up performing cylinder tests for every
single
>cylinder. You can see the effects of this if you look at the stats in
>the message window. You'll find that there are a *huge* number of
>cylinder tests, of which only a very small percentage were
successful.
>Whereas the union has about the same number of successful tests but a
>much lower number of unsuccessful ones.
>
>I did a scene a while ago with hundreds of small cylindrical holes in
a
>flat slab (rather than a torus) and experimented with cutting the
slab
>into smaller pieces with just a few holes in each piece. It turned
out
>that the rendering was fastest when each piece was so small that it
>contained only one hole.
>


Very informative; thank you! Throws a lot of light on some 'weird'
super-slow renders I've had .

Regards,
Anoop


Post a reply to this message

From: Nikodemus Siivola
Subject: Re: Slow CSG
Date: 14 Sep 2001 11:08:39
Message: <3ba21d77@news.povray.org>
"Mike Williams" <mik### [at] nospamplease> wrote:

> I did a scene a while ago with hundreds of small cylindrical holes in a
> flat slab (rather than a torus) and experimented with cutting the slab
> into smaller pieces with just a few holes in each piece. It turned out
> that the rendering was fastest when each piece was so small that it
> contained only one hole.

This should go in the docs, ot the VFAQ at least...

 -- Nikodemus


Post a reply to this message

From: Peter Popov
Subject: Re: Slow CSG
Date: 16 Sep 2001 15:58:38
Message: <nsp9qts1h8soc3tj90r9romribfukrnp1u@4ax.com>
On Thu, 13 Sep 2001 16:48:53 +0100, "Arnold the Aardvark"
<aar### [at] NOTTHIStubulidentatademoncouk> wrote:

>I created a shape by using the difference between a torus
>and a union of many cylinders. This renders very slowly.
>If I render the union of cylinders as the object it is much,
>much faster. I am using bound_by.
>
>Are there any other optimisations I can use for the difference?

Instead of intersecting the torus with the union of cylinders, make a
union of the intersection of each cylinder with the torus. POV will
then take much more advantage of autobounding and vista buffering than
it does with your current implementation.

The memory consumed with what I proposed is greater, but with "many"
being relatively sane, this shouldn't be a problem.

Hope this helps.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

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