--- ray/src/util/genBSDF.pl 2011/05/31 20:50:26 2.16 +++ ray/src/util/genBSDF.pl 2011/06/24 00:41:51 2.22 @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# RCSid $Id: genBSDF.pl,v 2.16 2011/05/31 20:50:26 greg Exp $ +# RCSid $Id: genBSDF.pl,v 2.22 2011/06/24 00:41:51 greg Exp $ # # Compute BSDF based on geometry and material description # @@ -13,6 +13,7 @@ sub userror { } my $td = mkdtemp("/tmp/genBSDF.XXXXXX"); chomp $td; +my @savedARGV = @ARGV; my $tensortree = 0; my $ttlog2 = 4; my $nsamp = 1000; @@ -22,6 +23,7 @@ my $geout = 1; my $nproc = 1; my $doforw = 0; my $doback = 1; +my $gunit = "Meter"; my @dim; # Get options while ($#ARGV >= 0) { @@ -32,6 +34,11 @@ while ($#ARGV >= 0) { shift @ARGV; } elsif ("$ARGV[0]" =~ /^[-+]g/) { $geout = ("$ARGV[0]" =~ /^\+/); + $gunit = $ARGV[1]; + if ($gunit !~ /^(?i)(meter|foot|inch|centimeter|millimeter)$/) { + die "Illegal geometry unit '$gunit': must be meter, foot, inch, centimeter, or millimeter\n"; + } + shift @ARGV; } elsif ("$ARGV[0]" =~ /^[-+]f/) { $doforw = ("$ARGV[0]" =~ /^\+/); } elsif ("$ARGV[0]" =~ /^[-+]b/) { @@ -98,20 +105,23 @@ die "Could not compile scene\n" if ( $? ); print ' -System +'; +print "\n"; +print +'System Name Manufacturer '; -printf "\t\t%.3f\n", $dim[5] - $dim[4]; -printf "\t\t%.3f\n", $dim[1] - $dim[0]; -printf "\t\t%.3f\n", $dim[3] - $dim[2]; +printf "\t\t%.3f\n", $dim[5] - $dim[4]; +printf "\t\t%.3f\n", $dim[1] - $dim[0]; +printf "\t\t%.3f\n", $dim[3] - $dim[2]; print "\t\tIntegral\n"; # Output MGF description if requested if ( $geout ) { - print "\t\t\n"; + print "\t\t\n"; printf "xf -t %.6f %.6f 0\n", -($dim[0]+$dim[1])/2, -($dim[2]+$dim[3])/2; open(MGFSCN, "< $mgfscn"); while () { print $_; } @@ -248,7 +258,7 @@ sub bg_tree_rtcontrib { "| rcalc -e 'r1=rand(($pn+.8681)*recno-.673892)' " . "-e 'r2=rand(($pn-5.37138)*recno+67.1737811)' " . "-e 'r3=rand(($pn+3.17603772)*recno+83.766771)' " . - "-e 'Dx=1-($pbeg+\$1+r1)/$ns;Dy:0;Dz=sqrt(1-Dx*Dx)' " . + "-e 'Dx=1-2*($pbeg+\$1+r1)/$ns;Dy:0;Dz=sqrt(1-Dx*Dx)' " . "-e 'xp=(\$3+r2)*(($dim[1]-$dim[0])/$nx)+$dim[0]' " . "-e 'yp=(\$2+r3)*(($dim[3]-$dim[2])/$ny)+$dim[2]' " . "-e 'zp=$dim[5-$forw]' -e 'myDz=Dz*($forw*2-1)' " . @@ -315,8 +325,10 @@ print CIE Illuminant D65 1nm.ssp ASTM E308 1931 Y.dsp - Reflection $side - LBNL/Shirley-Chiu +'; +print "\t\t\tReflection $side\n"; +print +' LBNL/Shirley-Chiu BRDF '; @@ -396,7 +408,8 @@ my $rtcmd = "rtcontrib $rtargs -h -ff -fo -n $nproc -c "-o '$td/%s.flt' -m $fmodnm -m $bmodnm $octree"; my $rccmd = "rcalc -e '$tcal' " . "-e 'mod(n,d):n-floor(n/d)*d' -e 'Kbin=mod(recno-.999,$ndiv)' " . - q{-if3 -e '$1=(0.265*$1+0.670*$2+0.065*$3)/KprojOmega'}; + q{-if3 -e 'oval=(0.265*$1+0.670*$2+0.065*$3)/KprojOmega' } . + q[-o '${ oval },']; if ( $doforw ) { $cmd = "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " . "-e 'xp=(\$3+rand(.12*recno+288))*(($dim[1]-$dim[0])/$nx)+$dim[0]' " .