--- ray/src/util/genBSDF.pl 2012/06/14 18:35:03 2.36 +++ ray/src/util/genBSDF.pl 2013/04/23 23:19:09 2.41 @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# RCSid $Id: genBSDF.pl,v 2.36 2012/06/14 18:35:03 greg Exp $ +# RCSid $Id: genBSDF.pl,v 2.41 2013/04/23 23:19:09 greg Exp $ # # Compute BSDF based on geometry and material description # @@ -24,7 +24,7 @@ my $nproc = 1; my $doforw = 0; my $doback = 1; my $pctcull = 90; -my $gunit = "Meter"; +my $gunit = "meter"; my @dim; # Get options while ($#ARGV >= 0) { @@ -108,6 +108,7 @@ print print "\n"; print 'System +BSDF @@ -117,18 +118,20 @@ print 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"; +print "\t\tOther\n"; +print " \n"; # Output MGF description if requested if ( $geout ) { - print "\t\t\n"; + print "\t\n"; + print "\n"; printf "xf -t %.6f %.6f 0\n", -($dim[0]+$dim[1])/2, -($dim[2]+$dim[3])/2; open(MGFSCN, "< $mgfscn"); while () { print $_; } close MGFSCN; print "xf\n"; - print "\t\t\n"; + print "\t\t\n"; + print "\t\n"; } -print " \n"; # Set up surface sampling my $nx = int(sqrt($nsamp*($dim[1]-$dim[0])/($dim[3]-$dim[2])) + .5); my $ny = int($nsamp/$nx + .5); @@ -197,17 +200,17 @@ print "\t\n"; print "\t\tTensorTree$tensortree\n"; print "\t\n"; -# Start rtcontrib processes for compute each side +# Start rcontrib processes for compute each side do_tree_rtcontrib(0) if ( $doback ); do_tree_rtcontrib(1) if ( $doforw ); } # end of sub do_tree_bsdf() -# Run rtcontrib process in background to generate tensor tree samples +# Run rcontrib process to generate tensor tree samples sub do_tree_rtcontrib { my $forw = shift; my $matargs = "-m $bmodnm"; - if ( !$forw || !$doback ) { $matargs .= " -m $fmodnm"; } + if ( !$forw || !$doback || $tensortree==3 ) { $matargs .= " -m $fmodnm"; } my $cmd = "rcontrib $rtargs -h -ff -fo -n $nproc -c $nsamp " . "-e '$disk2sq' -bn '$ns*$ns' " . "-b '$ns*floor(out_square_x*$ns)+floor(out_square_y*$ns)' " . @@ -245,7 +248,7 @@ sub do_tree_rtcontrib { "| $cmd"; } # print STDERR "Starting: $cmd\n"; - system "$cmd" || die "Failure running rtcontrib"; + system "$cmd" || die "Failure running rcontrib"; ttree_out($forw); } # end of do_tree_rtcontrib() @@ -254,8 +257,8 @@ sub ttree_out { my $forw = shift; my $side = ("Back","Front")[$forw]; my $cmd; -# Only output one transmitted distribution, preferring backwards -if ( !$forw || !$doback ) { +# Only output one transmitted anisotropic distribution, preferring backwards +if ( !$forw || !$doback || $tensortree==3 ) { print ' System @@ -263,8 +266,10 @@ print CIE Illuminant D65 1nm.ssp ASTM E308 1931 Y.dsp - Transmission - LBNL/Shirley-Chiu +'; +print "\t\t\tTransmission $side\n"; +print +' LBNL/Shirley-Chiu BTDF '; @@ -301,7 +306,7 @@ print print "\t\t\tReflection $side\n"; print ' LBNL/Shirley-Chiu - BRDF + BTDF '; $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " . @@ -379,7 +384,7 @@ kbin2(pol,azi) = select(kfindrow(1, pol), kbin = kbin2(Acos(abs(Dz)),Atan2(Dy,Dx)); '; my $ndiv = 145; -# Compute scattering data using rtcontrib +# Compute scattering data using rcontrib my @tfarr; my @rfarr; my @tbarr; @@ -402,8 +407,10 @@ $cmd = "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " . system "$cmd" || die "Failure running: $cmd\n"; @tfarr = `$rccmd $td/$fmodnm.flt`; die "Failure running: $rccmd $td/$fmodnm.flt\n" if ( $? ); +chomp(@tfarr); @rfarr = `$rccmd $td/$bmodnm.flt`; die "Failure running: $rccmd $td/$bmodnm.flt\n" if ( $? ); +chomp(@rfarr); } if ( $doback ) { $cmd = "cnt $ndiv $ny $nx | rcalc -of -e '$tcal' " . @@ -536,7 +543,7 @@ print Reflection Front LBNL/Klems Full LBNL/Klems Full - BRDF + BTDF '; # Output front reflection (transposed order) @@ -586,7 +593,7 @@ print Reflection Back LBNL/Klems Full LBNL/Klems Full - BRDF + BTDF '; # Output back reflection (transposed order)