#ifndef(IDEAL_AREA_LIGHT_INC_TEMP) #declare IDEAL_AREA_LIGHT_INC_TEMP = version; #version 3.7; #include "MyTransforms.inc" #ifndef(NITS_PER_WHITE) #declare NITS_PER_WHITE=600; #end #ifndef(GOLDEN_RATIO) #declare GOLDEN_RATIO=(1+sqrt(5))/2; #end #macro Factor_ColorVsFadeDistance(FD) (1/FD/FD/2) #end #macro Light_LambertWhiteSphere(_flux, _position, _radius, _resolution) //adjust input #local sphere_center=_position+<0,0,0>; #if(_resolution<1) #local resolution=1; #else #local resolution=int(_resolution); #end //local variables #local emission_area=4*pi*_radius*_radius; // m^2 #local luminance=_flux/emission_area/pi; // Nits //make POV-Ray light source #if(resolution<2) light_source{ <0,0,0> color rgb<1,1,1>*(_flux/4/pi/pi/NITS_PER_WHITE)*Factor_ColorVsFadeDistance(_radius/20) fade_power 2 fade_distance _radius/20 translate sphere_center } #else #for(i, 0, resolution-1) #local Z = -1+2*(1/2+i)/resolution; #local R = sqrt(1-Z*Z); #local Phi = i *2*pi*(1-1/GOLDEN_RATIO); #local ThisPoint = *_radius; light_source{ <0,0,0> color rgb<1,1,1>*(luminance*emission_area/resolution/pi/NITS_PER_WHITE)*Factor_ColorVsFadeDistance(_radius/20) spotlight radius 90 falloff 90 tightness 1 point_at ThisPoint fade_power 2 fade_distance _radius/20 translate sphere_center+ThisPoint } #end #end //look like object sphere{ sphere_center, _radius pigment{rgb<1,1,1>*luminance/NITS_PER_WHITE} finish{ambient 0 diffuse 0 emission 1} no_shadow no_radiosity } #end #macro Light_LambertWhiteCylinder(_flux, _start_point, _end_point, _radius, _resolution) //adjust input #local start_p=_start_point+<0,0,0>; #local end_p=_end_point+<0,0,0>; #local total_lgth=vlength(start_p-end_p); #if(total_lgth=0 | _radius<=0) #error "Light_LambertWhiteCylinder macro error" #end #if(_resolution<1) #local resolution=1; #else #local resolution=int(_resolution); #end //local variables associate with geometry #local direct_v=vnormalize(end_p-start_p); #local emission_area=2*pi*_radius*total_lgth; //local variables associate with physics #local luminance=_flux/emission_area/pi; //make POV-Ray light source #if(resolution<2) light_source{ <0,0,0> color rgb<1,1,1>*(_flux/4/pi/pi/NITS_PER_WHITE)*Factor_ColorVsFadeDistance(_radius/20) fade_power 2 fade_distance _radius/20 translate (end_p+start_p)/2 } #else #for(i, 0, resolution-1) #local Z = total_lgth*(1/2+i)/resolution; #local Phi = i *2*pi*(1-1/GOLDEN_RATIO); #local ThisPoint = ; light_source{ <0,0,Z> color rgb<1,1,1>*(luminance*emission_area/resolution/pi/NITS_PER_WHITE)*Factor_ColorVsFadeDistance(_radius/20) spotlight radius 90 falloff 90 tightness 1 point_at ThisPoint fade_power 2 fade_distance _radius/20 Trans_Align_Rotate(<0,0,1>,<0,0,0>, direct_v,<0,0,0>) translate start_p } #end #end //look like object cylinder{ start_p, end_p, _radius open texture{ pigment{rgb<1,1,1>*luminance/NITS_PER_WHITE} finish{ambient 0 diffuse 0 emission 1} } interior_texture{ pigment{rgb<0,0,0>} finish{ambient 0 diffuse 0 emission 0} } no_shadow no_radiosity } #end #macro Light_LambertWhiteDisc(_flux, _position, _face, _radius, _resolution) //adjust input #local disc_center=_position+<0,0,0>; #local face_vector=_face+<0,0,0>; #if(_resolution<1) #local resolution=1; #else #local resolution=int(_resolution); #end #if(vlength(face_vector)=0) #local face_vector=<0,0,1>; #else #local face_vector= vnormalize(face_vector); #end //local variables associate with geometry #local emission_area=pi*_radius*_radius; #if(vlength(face_vector-<0,0,1>)=0) #local rotate_axis=x; #local rotate_angle=0; #elseif(vlength(face_vector-<0,0,-1>)=0) #local rotate_axis=x; #local rotate_angle=pi; #else #local rotate_axis=vcross(<0,0,1>,face_vector); #local rotate_angle=acos(vdot(<0,0,1>,face_vector)); #if(vdot(vcross(rotate_axis,<0,0,1>),face_vector)<0) #local rotate_angle=-rotate_angle; #end #end //local variables associate with physics #local luminance=_flux/emission_area/pi; //make POV-Ray light source #if(resolution<2) light_source{ <0,0,0> color rgb<1,1,1>*(_flux/pi/pi/NITS_PER_WHITE)*Factor_ColorVsFadeDistance(0.0001) spotlight radius 90 falloff 90 tightness 1 point_at face_vector fade_power 2 fade_distance 0.0001 translate disc_center } #else #local GoldA = pi*(3-sqrt(5)); #for(i, 0, resolution-1) #local R = sqrt(1/2+i)/sqrt(resolution); #local Theta = i*2*pi*(1-1/GOLDEN_RATIO); #local ThisPoint = *_radius; #local ThisPoint=vaxis_rotate(ThisPoint,rotate_axis,degrees(rotate_angle)); light_source{ <0,0,0> color rgb<1,1,1>*(luminance*emission_area/resolution/pi/NITS_PER_WHITE)*Factor_ColorVsFadeDistance(0.0001) spotlight radius 90 falloff 90 tightness 1 point_at face_vector fade_power 2 fade_distance 0.0001 photons{ refraction on } translate disc_center+ThisPoint } #end #end //look like object disc{ disc_center, face_vector, _radius, texture{ pigment{rgb<1,1,1>*luminance/NITS_PER_WHITE} finish{ambient 0 diffuse 0 emission 1} } interior_texture{ pigment{rgb<0,0,0>} finish{ambient 0 diffuse 0 emission 0} } no_shadow no_radiosity } #end #macro Light_WhiteInfiniteDome(_illuminance, _place_distance, _resolution) #if(_resolution<1) #local resolution=1; #else #local resolution=int(_resolution); #end //local variables associate with physics #local luminance=_illuminance/pi; #for(i, 0, resolution-1) #local Z = (1/2+i)/resolution; #local R = sqrt(1-Z*Z); #local Phi = i *2*pi*(1-1/GOLDEN_RATIO); #local ThisPoint = *_place_distance; light_source{ ThisPoint color rgb<1,1,1>*(_illuminance*2/pi/resolution/NITS_PER_WHITE) parallel point_at <0,0,0> fade_power 0 } #end //look like object sphere{ <0,0,0>, _place_distance texture{ pigment{rgb<0,0,0>} finish{ambient 0 diffuse 0 emission 0} } interior_texture{ pigment{ function{ select(z,0,1) } color_map{ [0 rgb<0,0,0>] [1 rgb<1,1,1>*luminance/NITS_PER_WHITE] } } finish{ambient 0 diffuse 0 emission 1} } hollow no_shadow no_radiosity } #end #macro Light_WhiteInfiniteSphere(_illuminance, _place_distance, _resolution) //adjust input #if(_resolution<2) #local resolution=2; #else #local resolution=int(_resolution); #end //local variables associate with physics #local luminance=_illuminance/pi; #for(i, 0, resolution-1) #local Z = -1+2*(1/2+i)/resolution; #local R = sqrt(1-Z*Z); #local Phi = i *2*pi*(1-1/GOLDEN_RATIO); #local ThisPoint = *_place_distance; light_source{ ThisPoint color rgb<1,1,1>*(_illuminance*4/pi/resolution/NITS_PER_WHITE) parallel point_at <0,0,0> fade_power 0 } #end //look like object sphere{ <0,0,0>, _place_distance texture{ pigment{rgb<0,0,0>} finish{ambient 0 diffuse 0 emission 0} } interior_texture{ pigment{rgb<1,1,1>*luminance/NITS_PER_WHITE} finish{ambient 0 diffuse 0 emission 1} } hollow no_shadow no_radiosity } #end #macro Light_WhiteInfiniteDisc(_ground_illuminance, _face, _place_distance, _solid_angle, _resolution) //adjust input #local solid_angle=abs(_solid_angle); #local face_vector=_face+<0,0,0>; #if(_resolution<1) #local resolution=1; #else #local resolution=int(_resolution); #end #if(vlength(face_vector)=0) #local face_vector=<0,0,-1>; #else #local face_vector= vnormalize(face_vector); #if(face_vector.z>0) #local face_vector=-face_vector; #end #end //local variables associate with geometry #local center=-face_vector; #local angular_diameter=2*acos(1-solid_angle/2/pi); #if(vlength(face_vector-<0,0,-1>)=0) #local rotate_axis=x; #local rotate_angle=0; #else #local rotate_axis=vcross(<0,0,1>,center); #local rotate_angle=acos(vdot(<0,0,1>,center)); #end //local variables associate with physics #local luminance=_ground_illuminance*2/(vdot(face_vector,<0,0,-1>))/(1-cos(angular_diameter))/pi; //make POV-Ray light source #if(resolution<2) light_source{ center*_place_distance color rgb<1,1,1>*(_ground_illuminance/vdot(face_vector,<0,0,-1>)/pi/NITS_PER_WHITE) parallel point_at <0,0,0> fade_power 0 } #else #for(i, 0, resolution-1) #local Z = cos(angular_diameter/2)+(1-cos(angular_diameter/2))*(1/2+i)/resolution; #local R = sqrt(1-Z*Z); #local Phi = i *2*pi*(1-1/GOLDEN_RATIO); #local ThisPoint = ; #local ThisPoint=vaxis_rotate(ThisPoint,rotate_axis,degrees(rotate_angle))*_place_distance; light_source{ ThisPoint color rgb<1,1,1>*(luminance*solid_angle/pi/resolution/NITS_PER_WHITE) parallel point_at <0,0,0> fade_power 0 } #end #end //look like object sphere{ <0,0,0>, _place_distance clipped_by{ cone{ <0,0,0>,0, center*(_place_distance+0.1),(_place_distance+0.1)*tan(angular_diameter/2) } } texture{ pigment{rgb<0,0,0>} finish{ambient 0 diffuse 0 emission 0} } interior_texture{ pigment{rgb<1,1,1>*luminance/NITS_PER_WHITE} finish{ambient 0 diffuse 0 emission 1} } no_shadow no_radiosity } #end #version IDEAL_AREA_LIGHT_INC_TEMP; #end