// was +AM2 +A0.15 +R4 -J +FN +W1024 +H1024 // is +FN +W1024 +H1024 // Level of detail #declare dd = 20; //2; // Basic splitter ratios #declare xsr = 1/3; #declare ysr = 1/3; // Object indenter #declare is = 0.25; // Optional level limit #declare level_limit = 9; #version 3.5; #include "functions.inc" // ---------------------------------------- // Image dimensions #declare xd = 750/2; #declare yd = 750/2; light_source { // light's position (translated below) color rgb <1, 1, 1> // light's color parallel point_at } camera { location //-600>//-1200> direction 1.5*z right x*image_width/image_height look_at } // Pigment to scan #declare scan_pigment = pigment { image_map { tga "dripping_blood.tga" } scale } ///////////////////////////////////////////////////////////////////////////////// #macro similar_colors(c1,c2,c3,c4) #local epsilon = 0.0001; #if ( (abs(c1.red - c2.red) < epsilon) & (abs(c1.green - c2.green) < epsilon) & (abs(c1.blue - c2.blue) < epsilon) & (abs(c1.red - c3.red) < epsilon) & (abs(c1.green - c3.green) < epsilon) & (abs(c1.blue - c3.blue) < epsilon) & (abs(c1.red - c4.red) < epsilon) & (abs(c1.green - c4.green) < epsilon) & (abs(c1.blue - c4.blue) < epsilon) & (abs(c2.red - c3.red) < epsilon) & (abs(c2.green - c3.green) < epsilon) & (abs(c2.blue - c3.blue) < epsilon) & (abs(c2.red - c4.red) < epsilon) & (abs(c2.green - c4.green) < epsilon) & (abs(c2.blue - c4.blue) < epsilon) & (abs(c3.red - c4.red) < epsilon) & (abs(c3.green - c4.green) < epsilon) & (abs(c3.blue - c4.blue) < epsilon) ) #declare similar_answer = true; #else #declare similar_answer = false; #end #end ///////////////////////////////////////////////////////////////////////////////// #macro emit(left_x,bottom_y,right_x,top_y,ecolor,level) box { , #if (level = (level_limit-1)) texture { pigment { color rgb // *0.75 will reveal co-incident plate problem } finish { diffuse 1 ambient 0 } } #else texture { pigment { color rgb } finish { diffuse 1 ambient 0 } } #end } #end ///////////////////////////////////////////////////////////////////////////////// #macro scan(left_x,bottom_y,right_x,top_y,level,level_limited) // Get locations etc. #local dx = abs(right_x - left_x); #local cx = dx*xsr; #local dy = abs(top_y - bottom_y); #local cy = dy*ysr; // Further depths to go? Then go down further #if ( ((dx > dd) & (dy > dd) & (level_limited = off)) | ((level < level_limit) & (level_limited = on)) ) // Top left scan(left_x,bottom_y+cy, left_x+cx,top_y,level+1,level_limited) #local top_left_data = return_data; // Top right scan(left_x+cx,bottom_y+cy, right_x,top_y,level+1,level_limited) #local top_right_data = return_data; // Bottom left scan(left_x,bottom_y, left_x+cx,bottom_y+cy,level+1,level_limited) #local bottom_left_data = return_data; // Bottom right scan(left_x+cx,bottom_y, right_x,bottom_y+cy,level+1,level_limited) #local bottom_right_data = return_data; // Now analyse that data similar_colors (top_left_data[0], top_right_data[0], bottom_left_data[0], bottom_right_data[0] ) // Similars float up #if (similar_answer = true) #if ((top_left_data[1].red = 0) & (top_right_data[1].red = 0) & (bottom_left_data[1].red = 0) & (bottom_right_data[1].red = 0) ) emit(left_x,bottom_y,right_x,top_y,top_left_data[0],level) #declare return_data = array[2] {, <0,0,0>}; #else #declare return_data = array[2] {, <1,1,1>}; #end #else #local emitted = off; // Disimilars get emitted if they have not already been so #if ((top_left_data[1].red = 0)) emit(left_x,bottom_y+cy, left_x+cx,top_y, top_left_data[0],level) #local emitted = on; #end #if ((top_right_data[1].red = 0)) emit(left_x+cx,bottom_y+cy, right_x,top_y, top_right_data[0],level) #local emitted = on; #end #if ((bottom_left_data[1].red = 0)) emit(left_x,bottom_y, left_x+cx,bottom_y+cy, bottom_left_data[0],level) #local emitted = on; #end #if ((bottom_right_data[1].red = 0)) emit(left_x+cx,bottom_y, right_x,bottom_y+cy, bottom_right_data[0],level) #local emitted = on; #end #declare return_data = array[2] {, <1,1,1>}; #end #else // Get data //#local top_left_color = eval_pigment(scan_pigment,); //#local top_right_color = eval_pigment(scan_pigment,); #local bottom_left_color = eval_pigment(scan_pigment,); //#local bottom_right_color = eval_pigment(scan_pigment,); #declare return_data = array[2] {, <0,0,0>}; #end #end ///////////////////////////////////////////////////////////////////////////////// scan (0,0,xd,yd,1,on)