// Cāmeras e luzes padronizadas // Last edited on 2025-01-16 00:05:08 by stolfi #macro bcamlight(ctr,rad,cav,cad,foc,ape,liv,lid,lux) // {ctr} = center of interest in scene. // {rad} = approx radius of scene. // {cav} = vector pointing from {ctr} to camera; only its direction matters. // {cad} = the distance from camera to {ctr}. // {foc} = distance from {ctr} to the in-focus plane. // {ape} = aperture parameter for focus blur. // {liv} = vector pointing from {ctr} to light source; only its direction matters. // {lid} = distance from {ctr} to light source. // {lux} = a scaling factor for the intensity of standard light sources. #local cav = vnormalize(cav); #local cad = (cad); #local swh = sqrt(image_width/image_height); #local ard = 1.41*(rad)/(cad); // Camera width of view angle. #local fop = ctr + foc*cav; #debug concat("!! fop = ( ", str(fop.x,0,4), " ", str(fop.y,0,4), " ", str(fop.z,0,4), " )\n") camera { location (ctr) + cad*cav right -swh*ard*x up 1.0/swh*ard*y sky y look_at (ctr) #if (ape > 0) aperture ape*cad focal_point fop blur_samples 100 variance 0.0005 #end } #if (lux > 0) object{ lamp(liv,lid,lux) scale lid translate ctr } #end #end #macro lamp(liv,lid,lux) // A single lamp with strength {lux}. // The lamp is located on the X axis at distance 1 // from the origin. union{ object{ empty } light_source { lid*vnormalize(liv) color rgb lux*<1.0,1.0,1.0> } } #end