POV-Ray : Newsgroups : povray.general : Bounding behavior Server Time
29 Jul 2024 16:20:50 EDT (-0400)
  Bounding behavior (Message 1 to 8 of 8)  
From: Christian Froeschlin
Subject: Bounding behavior
Date: 28 Feb 2011 11:03:35
Message: <4d6bc757@news.povray.org>
I was trying to render a 3D puzzle by intersecting generic
puzzle tiles with a desired target shape and found it rendered
very slowly, even when intersecting the individual tiles before
creating a union. The effect was curious as it turned out

intersection
{
   object {A}
   object {B}
   bounded_by {B}
}

was much faster than

intersection
{
   object {A}
   object {B}
}

After some investigation I found that the problem was related to
the number of puzzle tiles completely outside the target shape, so
there seems to be some problem with empty intersections. I think
these should be discarded or at least get a small bounding box,
but they seem to be sticking around unbounded.

Also, I had originally expected to be able to use "split_union"
so I wouldn't have to intersect individual tiles (it's a bit more
effort due to scaling of final object size), but then found it was
only for photons. Such a setting might also be useful for bounding.

A small sample scene demonstrating both effects is attached.

Tested using 3.7 RC3


Post a reply to this message


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

From: Trevor G Quayle
Subject: Re: Bounding behavior
Date: 28 Feb 2011 13:00:00
Message: <web.4d6be20fd1c24daf81c811d20@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:
> I was trying to render a 3D puzzle by intersecting generic
> puzzle tiles with a desired target shape and found it rendered
> very slowly, even when intersecting the individual tiles before
> creating a union. The effect was curious as it turned out
>
> intersection
> {
>    object {A}
>    object {B}
>    bounded_by {B}
> }
>
> was much faster than
>
> intersection
> {
>    object {A}
>    object {B}
> }
>
> After some investigation I found that the problem was related to
> the number of puzzle tiles completely outside the target shape, so
> there seems to be some problem with empty intersections. I think
> these should be discarded or at least get a small bounding box,
> but they seem to be sticking around unbounded.
>

For any CSG, a bounding box is made as a single object that is known to contain
everything in the CSG.  So for an intersection operation, the bounding box will
be big enough to contain both (or all) your objects, regardless of how big the
remaining part is.  This is espescially an issue if one or mor objects doesn't
interesect, as it still gets included in the ray testing.

Fortunately in some cases, you have the benefit of knowing what your bounded
area should be and make a manual bounding box as you have done, and greatly
speed up rendering.  However, it is much more difficult to get POV to recognize
the need for a smaller bounding box.

This is even more extreme in difference operations as POV treats them as an
intersection of the first object with inverses of the subtracting objects.
Essentially the subtractiong objects are infinite in size.  (Try rendering a
plate with 10000 round holes in it for example.)

-tgq


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Bounding behavior
Date: 28 Feb 2011 14:45:34
Message: <4d6bfb5e$1@news.povray.org>
Trevor G Quayle wrote:

> For any CSG, a bounding box is made as a single object that is known to contain
> everything in the CSG.  So for an intersection operation, the bounding box will
> be big enough to contain both (or all) your objects, regardless of how big the
> remaining part is.  

Are you sure about this? The intersection of two finite
objects is contained in the intersection of their bounding
boxes so this should be more efficient than you describe.
In fact it seems to work quite well for my intersections,
even though one of the shapes is large.

There is only an issue when intersections turns out
to be empty and I think this is a fixable problem.

> This is even more extreme in difference operations as POV treats them as an
> intersection of the first object with inverses of the subtracting objects.
> Essentially the subtractiong objects are infinite in size.

Of course, an infinite box doesn't help much. Still I'd expect
the bounding box of the difference to be the bounding box of the
original finite object (which is still slow for many holes).


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Bounding behavior
Date: 28 Feb 2011 15:20:00
Message: <web.4d6c0297d1c24daf81c811d20@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:
> Trevor G Quayle wrote:
>
> > For any CSG, a bounding box is made as a single object that is known to contain
> > everything in the CSG.  So for an intersection operation, the bounding box will
> > be big enough to contain both (or all) your objects, regardless of how big the
> > remaining part is.
>
> Are you sure about this? The intersection of two finite
> objects is contained in the intersection of their bounding
> boxes so this should be more efficient than you describe.
> In fact it seems to work quite well for my intersections,
> even though one of the shapes is large.
>
> There is only an issue when intersections turns out
> to be empty and I think this is a fixable problem.
>
> > This is even more extreme in difference operations as POV treats them as an
> > intersection of the first object with inverses of the subtracting objects.
> > Essentially the subtractiong objects are infinite in size.
>
> Of course, an infinite box doesn't help much. Still I'd expect
> the bounding box of the difference to be the bounding box of the
> original finite object (which is still slow for many holes).


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Bounding behavior
Date: 28 Feb 2011 15:25:00
Message: <web.4d6c0393d1c24daf81c811d20@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:
> Trevor G Quayle wrote:
>
> > For any CSG, a bounding box is made as a single object that is known to contain
> > everything in the CSG.  So for an intersection operation, the bounding box will
> > be big enough to contain both (or all) your objects, regardless of how big the
> > remaining part is.
>
> Are you sure about this? The intersection of two finite
> objects is contained in the intersection of their bounding
> boxes so this should be more efficient than you describe.
> In fact it seems to work quite well for my intersections,
> even though one of the shapes is large.
>
> There is only an issue when intersections turns out
> to be empty and I think this is a fixable problem.
>
> > This is even more extreme in difference operations as POV treats them as an
> > intersection of the first object with inverses of the subtracting objects.
> > Essentially the subtractiong objects are infinite in size.
>
> Of course, an infinite box doesn't help much. Still I'd expect
> the bounding box of the difference to be the bounding box of the
> original finite object (which is still slow for many holes).

You may be right.  I am uncertain I guess how intersection is treated.  Perhaps
it is just an issue with non-intersecting boxes.

For subtraction, I do know I have tried in the past as an example to make a golf
ball from a sphere with many spheres subtracted.  This was unbearably slow.  But
switching to a blob with negative blob dimples was quite fast by comparison.

Maybe better answered by someone who knows the inner workings of bounding.

-tgq


Post a reply to this message

From: clipka
Subject: Re: Bounding behavior
Date: 28 Feb 2011 23:06:15
Message: <4d6c70b7$1@news.povray.org>
Am 28.02.2011 18:57, schrieb Trevor G Quayle:

> For any CSG, a bounding box is made as a single object that is known to contain
> everything in the CSG.  So for an intersection operation, the bounding box will
> be big enough to contain both (or all) your objects, regardless of how big the
> remaining part is.  This is espescially an issue if one or mor objects doesn't
> interesect, as it still gets included in the ray testing.

No; actually it's just the other way round: An intersection's bounding 
box will be computed as the intersection of all its elements' bounding 
boxes, with the effect that all elements' bounding boxes include the 
/full/ intersection's bounding box.

For instance, the intersection of a sphere {<0,0,0>,1} and a 
sphere{<0,0,1>,0.5} would be computed as follows:

1st sphere bounding box = box { <-1,-1,-1>, <1,1,1> }
2nd sphere bounding box = box { <-0.5,-0.5,0.5>, <0.5,0.5,1.5> }

intersection bounding box = box {
   <max(-1,-0.5),max(-1,-0.5),max(-1,0.5)>,
   <min(1,0.5),min(1,0.5),min(1,1.5)>
}
= box { <-0.5,-0.5,0.5>, <0.5,0.5,1> }

However, if the elements' bounding boxes don't have a common 
intersection at all, this doesn't work out; e.g.:

1st element bounding box = box { <-1,-1,-1>, <1,1,1> }
2nd element bounding box = box { <-0.5,-0.5,1.5>, <0.5,0.5,2.5> }

intersection bounding box = box {
   <max(-1,-0.5),max(-1,-0.5),max(-1,1.5)>,
   <min(1,0.5),min(1,0.5),min(1,2.5)>
}
= box { <-0.5,-0.5,1.5>, <0.5,0.5,1> }

which has a "smallest z" larger than its "largest z", which 
mathematically doesn't make any sense. My first guess would be that this 
is exactly what POV-Ray computes, but that it doesn't recognize it as 
bullshit.

> This is even more extreme in difference operations as POV treats them as an
> intersection of the first object with inverses of the subtracting objects.
> Essentially the subtractiong objects are infinite in size.  (Try rendering a
> plate with 10000 round holes in it for example.)

Not exactly; with differences, the problem is not that the difference's 
bounding box would be infinite (it isn't, because the volume covered by 
the difference is obviously at most the volume of the main object), nor 
that the subtracted objects would have an infinite bounding box (they 
actually don't either, because AFAIK the bounding boxes actually don't 
contain "all that is part of the object", but "all that is part of the 
object's surface"); instead, the problem is that for each intersection 
found with the main object, each and every differenced-away element is 
tested for insideness, without using any bounding box hierarchy that 
might speed things up. (Using the full scene's bounding hierarchy might 
be too expensive with large scenes, and individual CSG objects don't 
have any "private" bounding hierarchy.)


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Bounding behavior
Date: 1 Mar 2011 00:05:01
Message: <web.4d6c7dcdd1c24dafb05ef170@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 28.02.2011 18:57, schrieb Trevor G Quayle:
>
> > For any CSG, a bounding box is made as a single object that is known to contain
> > everything in the CSG.  So for an intersection operation, the bounding box will
> > be big enough to contain both (or all) your objects, regardless of how big the
> > remaining part is.  This is espescially an issue if one or mor objects doesn't
> > interesect, as it still gets included in the ray testing.
>
> No; actually it's just the other way round: An intersection's bounding
> box will be computed as the intersection of all its elements' bounding
> boxes, with the effect that all elements' bounding boxes include the
> /full/ intersection's bounding box.
>
> For instance, the intersection of a sphere {<0,0,0>,1} and a
> sphere{<0,0,1>,0.5} would be computed as follows:
>
> 1st sphere bounding box = box { <-1,-1,-1>, <1,1,1> }
> 2nd sphere bounding box = box { <-0.5,-0.5,0.5>, <0.5,0.5,1.5> }
>
> intersection bounding box = box {
>    <max(-1,-0.5),max(-1,-0.5),max(-1,0.5)>,
>    <min(1,0.5),min(1,0.5),min(1,1.5)>
> }
> = box { <-0.5,-0.5,0.5>, <0.5,0.5,1> }
>
> However, if the elements' bounding boxes don't have a common
> intersection at all, this doesn't work out; e.g.:
>
> 1st element bounding box = box { <-1,-1,-1>, <1,1,1> }
> 2nd element bounding box = box { <-0.5,-0.5,1.5>, <0.5,0.5,2.5> }
>
> intersection bounding box = box {
>    <max(-1,-0.5),max(-1,-0.5),max(-1,1.5)>,
>    <min(1,0.5),min(1,0.5),min(1,2.5)>
> }
> = box { <-0.5,-0.5,1.5>, <0.5,0.5,1> }
>
> which has a "smallest z" larger than its "largest z", which
> mathematically doesn't make any sense. My first guess would be that this
> is exactly what POV-Ray computes, but that it doesn't recognize it as
> bullshit.
>
> > This is even more extreme in difference operations as POV treats them as an
> > intersection of the first object with inverses of the subtracting objects.
> > Essentially the subtractiong objects are infinite in size.  (Try rendering a
> > plate with 10000 round holes in it for example.)
>
> Not exactly; with differences, the problem is not that the difference's
> bounding box would be infinite (it isn't, because the volume covered by
> the difference is obviously at most the volume of the main object), nor
> that the subtracted objects would have an infinite bounding box (they
> actually don't either, because AFAIK the bounding boxes actually don't
> contain "all that is part of the object", but "all that is part of the
> object's surface"); instead, the problem is that for each intersection
> found with the main object, each and every differenced-away element is
> tested for insideness, without using any bounding box hierarchy that
> might speed things up. (Using the full scene's bounding hierarchy might
> be too expensive with large scenes, and individual CSG objects don't
> have any "private" bounding hierarchy.)

Thanks for correcting and clearing that up for me.  I was in over my head on my
understanding of the inner workings and thought it was just an easy answer.

As far as the non-intersecting bounding box issue, perhaps someone should track
exactly how POV is handling the negative dimensions.  Perhaps there is a simple
fix in the code to clear that part up, eg either max all dimensions to 0 so
negatives aren't allowed, or ignore intersection if any dimension is less than
0.  The second is probably the best as the first can still leave a flat plate
bounding box if only one dimension is negative.

-tgq


Post a reply to this message

From: clipka
Subject: Re: Bounding behavior
Date: 1 Mar 2011 19:37:20
Message: <4d6d9140$1@news.povray.org>
Am 01.03.2011 06:02, schrieb Trevor G Quayle:

> As far as the non-intersecting bounding box issue, perhaps someone should track
> exactly how POV is handling the negative dimensions.  Perhaps there is a simple
> fix in the code to clear that part up, eg either max all dimensions to 0 so
> negatives aren't allowed, or ignore intersection if any dimension is less than
> 0.  The second is probably the best as the first can still leave a flat plate
> bounding box if only one dimension is negative.

There's actually already code in POV-Ray that checks for this condition; 
it just takes an unsuitable action: Apparently presuming something went 
wrong during bounding box computations, it leaves the bounding box at 
its initialization value, which is "infinite" (and is intended to print 
a warning, but that code is disabled).


Post a reply to this message

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