|
![](/i/fill.gif) |
Note: this is NOT simply another question about why CSG differences are
so slow (well, it sort of is, but. . . .)
(For the benefit of those who don't know, see Mike Williams'
http://www.econym.demon.co.uk/holetut/index.htm )
As I posted in P.B.I., I "found" (I'm sure many people have beat me to
it, but I hadn't seen it before) a simple way to greatly increase
rendering speed for a general CSG difference, by simply using a "blob"
rather than a "union" to make the "holes." In addition, there seems to
be yet another (smaller) improvement, by intersecting with a blob full
of holes, rather than simply differencing with a positive
"hole-punching" blob.
For example, the scene:
//////////
#declare UnionDiff = union {
#local J = 0;
#while (J < 30)
#local I = 0;
#while (I < 30)
cylinder { <0, -10, 0>, <0, 10, 0>, 0.2 translate <I, 0, J> }
#local I = I + 0.5;
#end
#local J = J + 0.5;
#end
pigment { color rgb z }
}
difference { box <-2, -3, -2>, <32, 3, 32> pigment { color rgb x } }
UnionDiff }
camera { angle 35 location <15, 60, 15> look_at <15, 0, 15> }
light_source { <50, 200, 50> rgb 1 }
//////////
renders at about 30 pixels per second on my machine (I didn't have the
patience to render the whole scene), while
//////////
#declare BlobDiff = blob { threshold 0.25
#local J = 0;
#while (J < 30)
#local I = 0;
#while (I < 30)
cylinder { <0, -10, 0>, <0, 10, 0>, 0.2, 2 translate <I, 0, J> }
#local I = I + 0.5;
#end
#local J = J + 0.5;
#end
pigment { color rgb z }
}
difference { box <-2, -3, -2>, <32, 3, 32> pigment { color rgb x } }
BlobDiff }
camera { angle 35 location <15, 60, 15> look_at <15, 0, 15> }
light_source { <50, 200, 50> rgb 1 }
//////////
renders at about 340 pps
and
//////////
#declare BlobNegative = blob { threshold 0.25
sphere { 0, 1, 1 scale <45, 10, 45> translate <15, 0, 15> }
#local J = 0;
#while (J < 30)
#local I = 0;
#while (I < 30)
cylinder { <0, -10, 0>, <0, 10, 0>, 0.2, -2 translate <I, 0, J> }
#local I = I + 0.5;
#end
#local J = J + 0.5;
#end
pigment { color rgb z }
}
intersection { box <-2, -3, -2>, <32, 3, 32> pigment { color rgb x } }
BlobNegative }
camera { angle 35 location <15, 60, 15> look_at <15, 0, 15> }
light_source { <50, 200, 50> rgb 1 }
//////////
renders at about 380 pps.
I know why differencing with a union is so slow, but I was wondering
A) Why is differencing with a blob so much faster?
B) (Depending on the answer to A) Would it be possible to use whatever
bounding improvements cause the blob difference to be faster to improve
the CSG difference? (Since I don't know jack about programming, this is
probably a stupid question that is almost impossible to answer at a
level I could understand, but I still have to ask it.)
C) Any idea why the intersection with a blob full of holes (3rd
example) should be faster than differencing with a positive blob (2nd
example)? Or is it purely an accident of the scenes I happened to choose?
(Note that these times were with "antialias off." The differences are
much greater -- even between the two blob methods (in absolute numbers
and in proportion) when AA 0.2 is used (as you might expect, since the
antialiasing takes place around the "holes.")
Dave Matthews
Post a reply to this message
|
![](/i/fill.gif) |