|
|
Wasn't it Tom A. who wrote:
>General question - is difference an expensive operation?
Differencing a large number of small objects from one large object is
notoriously slow. What happens is that the automatic bounding ends up
being rather unhelpful.
Normally if you've got lots of small objects, POV performs some quick
bound tests for each ray and then only bothers to test those objects for
which the ray hits the bounds. So only a few objects are tested for each
ray.
However, in your case, there's probably only one bounding box, and it's
the size of the large object. POV then ends up testing every object for
every ray.
You can observe the effect by rendering at small size and looking at the
statistics for the numbers of bounds tests and tests for whatever
primitive your difference object is.
You may find that it's possible to slice your large object up into
smaller chunks (e.g. by intersecting several copies of it with a set of
boxes) applying the difference to those chunks and then unioning the
whole thing back together again.
Below is my usual example file of a slab with lots of cylindrical holes
in it. If you set N=20 M=1 then you get one box with 400 cylindrical
holes. render it at 320*240 and the stats say 33611600 cylinder tests.
That's an average of over 437 cylinder tests per ray. If you set N=1
M=20 then you the slab is split into 400 pieces each containing one
hole. Render that and the stats say 16861 cylinder tests. That's 0.2
cylinder tests per ray, and it renders about 107 times faster.
(If your scene contains only the difference object, then you may find
that bounding gets switched off altogether, because POV doesn't think
it's generally worthwhile to bound less than three objects. Forcing
bounding to occur can give a bit of speed improvement in such cases.)
#declare N = 1; // Each box has N*N holes
#declare M = 20; // There are M*M boxes
camera { location <M*N/2, M*N/2, -50.0> look_at <M*N/2, M*N/2, 0>}
sky_sphere { pigment { gradient y color_map { [0.0 color rgb <0,.3,.8>]
[1.0 color rgb 1] }}}
light_source { <-20,50,-20> colour rgb 1}
// Build a box with N*N cylindrical holes
#declare Holes = 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
}
// Glue together M*M boxes into one slab
#declare Slab = union {
#declare xx=0;
#while (xx < M)
#declare yy = 0;
#while (yy < M)
object {Holes translate <xx*N,yy*N,0>}
#declare yy = yy + 1;
#end
#declare xx=xx+1;
#end
pigment {rgb 0.5}
}
object {Slab}
Post a reply to this message
|
|