--- ray/src/util/genBSDF.pl 2019/06/10 13:58:49 2.83 +++ ray/src/util/genBSDF.pl 2024/01/05 18:04:28 2.91 @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# RCSid $Id: genBSDF.pl,v 2.83 2019/06/10 13:58:49 greg Exp $ +# RCSid $Id: genBSDF.pl,v 2.91 2024/01/05 18:04:28 greg Exp $ # # Compute BSDF based on geometry and material description # @@ -13,7 +13,7 @@ sub userror { exit 1; } my ($td,$radscn,$mgfscn,$octree,$fsender,$bsender,$receivers,$facedat,$behinddat,$rmtmp); -my ($tf,$rf,$tb,$rb,$tfx,$rfx,$tbx,$rbx,$tfz,$rfz,$tbz,$rbz,$cph); +my ($tf,$rf,$tb,$rb,$tfx,$rfx,$tbx,$rbx,$tfz,$rfz,$tbz,$rbz); my ($curphase, $recovery); if ($#ARGV == 1 && "$ARGV[0]" =~ /^-rec/) { $td = $ARGV[1]; @@ -57,7 +57,6 @@ if ($windoz) { $rfz = "$td\\rfz.dat"; $tbz = "$td\\tbz.dat"; $rbz = "$td\\rbz.dat"; - $cph = "$td\\phase.txt"; $rmtmp = "rd /S /Q $td"; } else { $radscn = "$td/device.rad"; @@ -80,7 +79,6 @@ if ($windoz) { $rfz = "$td/rfz.dat"; $tbz = "$td/tbz.dat"; $rbz = "$td/rbz.dat"; - $cph = "$td/phase.txt"; $rmtmp = "rm -rf $td"; } my @savedARGV = @ARGV; @@ -197,7 +195,7 @@ my $ns = 2**$ttlog2; my $nx = int(sqrt($nsamp*($dim[1]-$dim[0])/($dim[3]-$dim[2])) + 1); my $ny = int($nsamp/$nx + 1); $nsamp = $nx * $ny; -$rfluxmtx .= " -n $nproc -c $nsamp"; +$rfluxmtx .= " -n $nproc -c $nsamp -cs 3"; if ( !defined $recovery ) { open(MYAVH, "> $td/savedARGV.txt"); foreach (@savedARGV) { @@ -213,6 +211,7 @@ if ( !defined $recovery ) { printf MGFSCN "xf -t %.6f %.6f 0\n", -($dim[0]+$dim[1])/2, -($dim[2]+$dim[3])/2; close MGFSCN; if ( $mgfin ) { + die "+mgf requires input file with +geom\n" if ($#ARGV < 0); system qq{mgfilt "#,o,xf,c,cxy,cspec,cmix,m,sides,rd,td,rs,ts,ir,v,p,n,f,fh,sph,cyl,cone,prism,ring,torus" @ARGV >> $mgfscn}; } else { system "rad2mgf $radscn >> $mgfscn"; @@ -324,8 +323,9 @@ sub do_ttree_dir { qq{-e "r2=rand(-5.37138*recno+67.1737811)" } . qq{-e "r3=rand(+3.17603772*recno+83.766771)" } . qq{-e "r4=rand(-1.5839226*recno-59.82712)" } . - qq{-e "Dx=1-2*(\$1+r1)/$ns" } . - qq{-e "Dy=min(1/$ns,sqrt(1-Dx*Dx))*(2*r2-1)" } . + qq{-e "odds(n):if(.5*n-floor(.5*n)-.25,-1,1)"} . + qq{-e "Dx=1-(\$1+r1)/$ns2" } . + qq{-e "Dy=min(1/$ns,sqrt(1-Dx*Dx))*odds(\$1)*r2" } . qq{-e "Dz=sqrt(1-Dx*Dx-Dy*Dy)" } . qq{-e "xp=(\$3+r2)*(($dim[1]-$dim[0])/$nx)+$dim[0]" } . qq{-e "yp=(\$2+r3)*(($dim[3]-$dim[2])/$ny)+$dim[2]" } . @@ -339,8 +339,9 @@ sub do_ttree_dir { qq{-e 'r2=rand(-5.37138*recno+67.1737811)' } . qq{-e 'r3=rand(+3.17603772*recno+83.766771)' } . qq{-e 'r4=rand(-1.5839226*recno-59.82712)' } . - qq{-e 'Dx=1-2*(\$1+r1)/$ns' } . - qq{-e 'Dy=min(1/$ns,sqrt(1-Dx*Dx))*(2*r2-1)' } . + qq{-e 'odds(n):if(.5*n-floor(.5*n)-.25,-1,1)' } . + qq{-e 'Dx=1-(\$1+r1)/$ns2' } . + qq{-e 'Dy=min(1/$ns,sqrt(1-Dx*Dx))*odds(\$1)*r2' } . qq{-e 'Dz=sqrt(1-Dx*Dx-Dy*Dy)' } . qq{-e 'xp=(\$3+r3)*(($dim[1]-$dim[0])/$nx)+$dim[0]' } . qq{-e 'yp=(\$2+r4)*(($dim[3]-$dim[2])/$ny)+$dim[2]' } . @@ -434,7 +435,7 @@ sub ttree_comp { } } if ($pctcull >= 0) { - my $avg = ( $dorecip && "$typ" =~ /^r[fb]/ ) ? " -a" : ""; + my $avg = ( $dorecip && ( $tensortree == 3 || "$typ" =~ /^r[fb]/ ) ) ? " -a" : ""; my $pcull = ("$spec" eq "Visible") ? $pctcull : (100 - (100-$pctcull)*.25) ; if ($windoz) {