|
|
In message <b8f### [at] lazysodorguk>, Alex <pov### [at] lazysodorguk>
writes
<snip>
>
>I'll have a little play after I've had some lunch, see what I can come
>up with. There's more than one way to skin a cat.
This code uses a lot less memory (even with radiosity added), but it
does render much more slowly. Your cubes approach is well suited to
hierarchical bounding. My method generates a union of long and
progressively thinner boxes, which are used with 2 other rotated copies
to cut holes out of a cube. This can't be efficiently bound.
It's worth noting that my level 4 is equivalent to your level 5, we both
start from a different point.
global_settings{
assumed_gamma 1.0
max_trace_level 6
adc_bailout 1/250
}
#include "colors.inc"
// posn - x,y co-ords of centre of current square
// sz - width of square. centre 3rd will be cut out,
// surrounding 8 sections call macro recursively
// levl - current recursion level
#macro do_holes(posn,sz,levl)
box{posn-<1,1,0>*sz/6-z*0.51,posn+<1,1,0>*sz/6+z*0.51}
#if (levl>0)
do_holes(posn+<1,0,0>/3*sz,sz/3,levl-1)
do_holes(posn+<1,1,0>/3*sz,sz/3,levl-1)
do_holes(posn+<0,1,0>/3*sz,sz/3,levl-1)
do_holes(posn+<-1,1,0>/3*sz,sz/3,levl-1)
do_holes(posn+<-1,0,0>/3*sz,sz/3,levl-1)
do_holes(posn+<-1,-1,0>/3*sz,sz/3,levl-1)
do_holes(posn+<0,-1,0>/3*sz,sz/3,levl-1)
do_holes(posn+<1,-1,0>/3*sz,sz/3,levl-1)
#end //if levl
#end //macro
#declare holes=union{
do_holes(<0,0>,1,2) // last number here controls recursion depth
}
difference{
box{-1/2,1/2}
object {holes}
object {holes rotate <90,0,0>}
object {holes rotate <0,90,0>}
texture{
pigment{rgb <8,3,0>/9}
finish{ambient 0 diffuse 1}
}
}
light_source{<60,50,-50> colour Gray40}
light_source{<-60,50,-50> colour Gray20}
light_source{<0,-70,-50> colour Gray10}
camera {
right 4*x
up 3*y
direction 10*z
location <4,3,-7>
look_at <0,0,0>
}
Hope this is of some help.
Another thought: Mine is too slow. You could maybe combine the two
approaches? Declare mine at level 2 as an object, and use that in place
of the source cube in your code at level 2.
--
Alex
Post a reply to this message
|
|