// Sample scene to demonstrate non-intuitive bounding behavior #version 3.7 #declare TM_SANDBOX = 0; // Play with your own settings below separator line #declare TM_TILING_OK = 1; // Build sparse object from manually bounded shaped tiles #declare TM_TILING_SLOW= 2; // Build sparse object from automatically bounded shaped tiles #declare TM_UNION_OK = 3; // Build rich object from automatically bounded shaped tiles #declare TM_UNION_SLOW = 4; // Build rich object as shaped union of unshaped tiles #declare TEST_MODE = TM_TILING_OK; // ******************************************************************************** // Detailed test settings #declare BM_AUTO_UNION = 0; // Naively intersect union with target shape #declare BM_AUTO_TILE = 1; // Intersect individual tiles before creating union #declare BM_MANUAL_TILE = 2; // As BM_AUTOTILE but tile intersection explicitely bounded by original TILE #declare BM_MANUAL_BOX = 3; // As BM_AUTOTILE but tile intersection explicitely bounded by original TILE's bounding box #declare BT_BIG_SPHERE = 0; // Most intersections non-empty, automatic bounding ok #declare BT_SMALL_SPHERE = 1; // Most tiles don't intersect target shape, automatic bounding extremely inefficient. // Custom values only used with TM_SANDBOX #declare N = 30; // Number of blocks per axis (WARNING: Creates N^3 blocks!!!) #declare BOUNDING_MODE = BM_AUTO_TILE; #declare BOUNDING_TARGET = BT_BIG_SPHERE; // Predefined test cases #if (TEST_MODE = TM_TILING_OK) #declare N = 10; #declare BOUNDING_MODE = BM_MANUAL_BOX; #declare BOUNDING_TARGET = BT_SMALL_SPHERE; #end #if (TEST_MODE = TM_TILING_SLOW) #declare N = 10; #declare BOUNDING_MODE = BM_AUTO_TILE; #declare BOUNDING_TARGET = BT_SMALL_SPHERE; #end #if (TEST_MODE = TM_UNION_OK) #declare N = 30; #declare BOUNDING_MODE = BM_AUTO_TILE; #declare BOUNDING_TARGET = BT_BIG_SPHERE; #end #if (TEST_MODE = TM_UNION_SLOW) #declare N = 30; #declare BOUNDING_MODE = BM_AUTO_UNION; #declare BOUNDING_TARGET = BT_BIG_SPHERE; #end // ******************************************************************************** // Actual scene #include "colors.inc" camera { location <0.0, 1.0, -5.0> look_at <0.0, 1.0, 0.0> angle 90 } global_settings { assumed_gamma 1.0 max_trace_level N } light_source {<-50, 50, -50> color White} sphere { 0, 1000 pigment {color SkyBlue} hollow } plane {y, 0 pigment{checker color White color Black}} // A simple test tile that is a bit more complicated than a bounding box #declare TILE0 = box {-0.45,0.45 rotate 45*z rotate 45*x scale 1/sqrt(2)} #declare TILE = union {object {TILE0} object {TILE0 translate 0.5}} // The desired target shape of the final object within the unit cube #if (BOUNDING_TARGET = BT_BIG_SPHERE) #declare SHAPE = sphere {0.5,0.5} #else #declare SHAPE = sphere {0.5,0.2} #end // N x N x N block of scaled tiles filling the unit cube #declare BLOCK = union { #for (X, 0, N-1, 1) #for (Y, 0, N-1, 1) #for (Z, 0, N-1, 1) #local TILE_INSTANCE = object {TILE translate } #if (BOUNDING_MODE = BM_AUTO_UNION) object {TILE_INSTANCE} #else intersection { object {SHAPE scale N} object {TILE_INSTANCE} #if (BOUNDING_MODE = BM_MANUAL_TILE) bounded_by {object {TILE_INSTANCE}} #end #if (BOUNDING_MODE = BM_MANUAL_BOX) bounded_by {box{min_extent(TILE_INSTANCE),max_extent(TILE_INSTANCE)}} #end } #end #end #end #end scale 1/N } #declare TARGET = #if (BOUNDING_MODE = BM_AUTO_UNION) intersection { object {SHAPE} object {BLOCK} } #else object {BLOCK} #end object { TARGET translate -0.5*x scale 5 pigment {color rgbf <1,0,0,0.8>} finish {specular 0.4 roughness 0.003 reflection {0.2, fresnel on} conserve_energy} interior {ior 1.5} }