// Last edited on 2025-01-28 22:22:33 by stolfi // Light gauge for photometric stereo. #version 3.7; background{ color rgb < 0.000, 0.000, 0.000 > } #include "parms.inc" #declare empty = sphere{ < 10,10,10 >, 0.0001 texture{ pigment{ color rgb <1,1,0> } } } // OBJECTS ////////////////////////////////////////////////// #if (obj_mask = 1) #declare obj_pigment = pigment{ color rgb <1,1,1> } #declare obj_amb = 1.0; // Override {parms.inc} #declare obj_spc = 0.0; // Override {parms.inc} #elseif (obj_textured = 0) #declare obj_pigment = pigment{ color rgb <1,1,1> } #else #declare obj_pigment = pigment{ granite turbulence 1 color_map { [0.00 color rgb obj_clr_lite ] [0.25 color rgb obj_clr_lite ] [0.25 color rgb obj_clr_dark ] [0.50 color rgb obj_clr_dark ] [0.50 color rgb obj_clr_lite ] [0.75 color rgb obj_clr_lite ] [0.75 color rgb obj_clr_dark ] [1.00 color rgb obj_clr_dark ] } scale 0.25 } #end #declare obj_dif = 1 - obj_amb - obj_spc; #declare obj_tx = texture{ pigment{ obj_pigment } finish{ diffuse obj_dif brilliance obj_brt ambient obj_amb specular obj_spc } } #macro pyramid() intersection{ box{ < -1.1, -1.1, -0.1 >, < +1.1, +1.1, +1.1 > } // BBox. plane{ -z, -0.001 } #local k = 0; #while (k < 4) plane{ z, 0 rotate 45*y translate 1*x rotate k*90*z } #local k = k + 1; #end scale obj_rad translate obj_ctr texture{ obj_tx } } #end #macro ball() sphere{ obj_ctr, obj_rad texture{ obj_tx } } #end // BACKGROUND (FLOOR) PLANE ///////////////////////////////////////// #declare ground_tx = texture{ pigment{ granite turbulence 1 color_map { [0.00 color rgb ground_clr_lite ] [0.25 color rgb ground_clr_lite ] [0.25 color rgb ground_clr_dark ] [0.50 color rgb ground_clr_dark ] [0.50 color rgb ground_clr_lite ] [0.75 color rgb ground_clr_lite ] [0.75 color rgb ground_clr_dark ] [1.00 color rgb ground_clr_dark ] } scale 0.25 } finish{ diffuse obj_dif brilliance obj_brt ambient obj_amb specular 0.000 } } #macro ground() #local ground_rad = 1.40*obj_rad; box{ < -ground_rad, -ground_rad, -0.01 >, < +ground_rad, +ground_rad, -0.005 > texture{ ground_tx } } #end // WHITE LAMBERTIAN LIGHT GAUGE //////////////////////////////////////// #declare gauge_amb = obj_amb; #declare gauge_spc = 0.000; #declare gauge_dif = 1 - gauge_amb - gauge_spc; #declare gauge_tx = texture{ pigment{ color rgb <1,1,1> } finish { diffuse gauge_dif brilliance obj_brt ambient gauge_amb specular gauge_spc } } #declare gauge_rad = 0.30*obj_rad; #macro gauge() sphere{ <0,0,0>, gauge_rad texture{ gauge_tx } } #end // BRIGHTNESS LINEARITY SCALE //////////////////////////////////////// #macro brtscale_chip(rx,ry,lux) #local tx_chip = texture{ pigment{ color rgb lux*<1,1,1> } finish{ ambient 1 diffuse 0 brilliance obj_brt specular 0 } } box{ < -rx, -ry, 0.000 >, < +rx, +ry, 0.010 > texture{ tx_chip } } #end #macro brtscale() #local brtscale_bg_tx = texture{ pigment{ color rgb < 0.500, 0.500, 0.500 > } finish{ ambient 1 diffuse 0 brilliance obj_brt specular 0 } } #local xtot = 2.75*obj_rad; #local ytot = 0.40*obj_rad; #local n = 11; #local xstep = xtot/n; #local rx = 0.9*xstep/2; #local ry = 0.9*ytot/2; union{ #local xc = -(n-1)/2*xstep; #local k = 0; #while (k < n) #local lux = k/(n-1); object{ brtscale_chip(rx,ry,lux) translate xc*x translate 0.011*z } #local xc = xc + xstep; #local k = k + 1; #end box{ < -xtot/2, -ytot/2, 0.001 >, < +xtot/2, +ytot/2, 0.010 > texture{ brtscale_bg_tx } } scale obj_rad translate < obj_ctr.x, obj_ctr.y - ytot/2 - 1.50*obj_rad, cam_foc > no_shadow } #end // FOCUS+APERTURE CAPTION ///////////////////////////////////////////////// #declare focus_caption_tx = texture{ pigment{ color rgb < 1.000, 0.900, 0.600 > } finish { diffuse 0.000 brilliance obj_brt ambient 1.000 specular 0.000 } } #macro focus_caption(foc, ape) #local ytot = 0.60*obj_rad; #local xcap = concat("zf ", str(foc, 0,4), " ap ", str(ape, 0,4)) #local ocap = text{ ttf "ttf/arialbd.ttf" xcap 0.01, 0 scale 0.250 texture{ focus_caption_tx } } #local omin = min_extent(ocap); #local omax = max_extent(ocap); #local owx = omax.x - omin.x; object{ ocap translate -0.5*owx*x translate < obj_ctr.x, obj_ctr.y + 1.45*obj_rad + ytot/2, foc > no_shadow } #end // LIGHT DIRECTION CAPTION //////////////////////////////////// #declare light_caption_tx = texture{ pigment{ color rgb < 1.000, 0.900, 0.600 > } finish { diffuse 0.000 brilliance obj_brt ambient 1.000 specular 0.000 } } #macro light_caption(sdir) #local ytot = 0.60*obj_rad; #local xcap = concat("L ", str(sdir.x, 7,4), " ", str(sdir.y, 7,4), " ", str(sdir.z, 7,4)) #local ocap = text{ ttf "ttf/arialbd.ttf" xcap 0.01, 0 scale 0.220 texture{ light_caption_tx } } #local omin = min_extent(ocap); #local omax = max_extent(ocap); #local owx = omax.x - omin.x; object{ ocap translate -0.5*owx*x rotate 90*z translate < obj_ctr.x - 1.45*obj_rad - ytot/2, obj_ctr.y, cam_foc > no_shadow } #end // Z FOCUS SCALE ////////////////////////////////////////////// #declare zscale_tx = texture{ pigment{ color rgb < 1.000, 0.900, 0.600 > } finish { diffuse 0.000 brilliance obj_brt ambient 1.000 specular 0.000 } } #declare zscale_bg_tx = texture{ pigment{ color rgb < 0.100, 0.100, 0.600 > } finish { diffuse 0.000 brilliance obj_brt ambient 1.000 specular 0.000 } } #macro zmark(Z) #local lab = str(Z,0,1) union{ union{ text{ ttf "ttf/arialbd.ttf" lab 0.01, 0 rotate 90*z translate 0.350*x - 0.250*y scale 0.180 } cone{ < 0,0,0 >, 0.03, <0,-0.2,0>, 0.00 scale < 1, 1, 0.05 > translate -0.1*y } texture{ zscale_tx } } box{ < -0.10, -0.08, -0.001 >, < +0.10, +0.23, +0.001 > texture{ zscale_bg_tx } } translate 0.050*y } #end #macro zscale() #local xtot = 2.75*obj_rad; #local ytot = 0.60*obj_rad; #local ztot = 2.00*obj_rad; #local n = 11; #local xstep = xtot/n; #local zstep = ztot/(n-1); #local xc = -(n-1)/2*xstep; #local zc = 0; union{ #local k = 0; #while (k < n) object{ zmark(zc) translate xc*x + zc*z } #local xc = xc + xstep; #local zc = zc + zstep; #local k = k + 1; #end rotate -90*z translate < obj_ctr.x + 1.45*obj_rad + ytot/2, obj_ctr.y, 0 > no_shadow } #end // ALL TOGETHER NOW ////////////////////////////////////////////////// #declare scene = union{ #if (obj = 0) object{ ball() } #elseif (obj = 1) object{ pyramid() } #else pau() #end #if (obj_mask = 0) object{ brtscale() } object{ zscale() } object{ focus_caption(cam_foc, cam_ape) } object{ light_caption(light_dir) } object{ ground() } object{ gauge() translate (1.45*obj_rad + gauge_rad)*< +1, +1, 0 > } object{ gauge() translate (1.45*obj_rad + gauge_rad)*< +1, -1, 0 > } object{ gauge() translate (1.45*obj_rad + gauge_rad)*< -1, +1, 0 > } object{ gauge() translate (1.45*obj_rad + gauge_rad)*< -1, -1, 0 > } #else object{ empty } // To avoid stupid POV-ray message. #end } #include "eixos.inc" #include "bcamlight.inc" #macro disk(clr) // A disk of radius 0.20 cylinder{ <0,0,-0.001>, <0,0,+0.001>, 0.20 texture{ pigment{ color rgb clr } finish{ ambient 1 diffuse 0 brilliance obj_brt } } } #end #local gubed = 0; // Debug. #if (gubed) object{ eixos(2.0) } // object{ zmark(0.0) scale 5.0 texture{ zscale_tx } } // object{ scene rotate 180*z rotate -89*x } object{ scene } object{ disk( <1.000,1.000,0.000>) translate -1.000*x translate -1.000*z } object{ disk( <1.000,0.500,0.000>) translate -0.500*x translate -0.100*z } object{ disk( <1.000,0.000,1.000>) translate 00.000*x translate 00.000*z } object{ disk( <0.000,0.500,1.000>) translate +0.500*x translate +0.100*z } object{ disk( <0.000,1.000,1.000>) translate +1.000*x translate +1.000*z } object{ disk( <1.000,0.000,0.000>) translate +1.500*x translate +2.000*z } #else object{ scene } #end #declare scene_ctr = < obj_ctr.x, obj_ctr.y, 0 >; #declare scene_rad = 3.0 * obj_rad; #declare cam_dir = < 0, 0, 1 >; #declare cam_dist = 2000*obj_rad; bcamlight(scene_ctr, scene_rad, cam_dir, cam_dist, cam_foc, cam_ape, light_dir, light_dist, light_brt)