ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/genBSDF.pl
(Generate patch)

Comparing ray/src/util/genBSDF.pl (file contents):
Revision 2.79 by greg, Tue Apr 17 18:11:17 2018 UTC vs.
Revision 2.90 by greg, Fri Sep 22 18:01:32 2023 UTC

# Line 13 | Line 13 | sub userror {
13          exit 1;
14   }
15   my ($td,$radscn,$mgfscn,$octree,$fsender,$bsender,$receivers,$facedat,$behinddat,$rmtmp);
16 < my ($tf,$rf,$tb,$rb,$tfx,$rfx,$tbx,$rbx,$tfz,$rfz,$tbz,$rbz,$cph);
16 > my ($tf,$rf,$tb,$rb,$tfx,$rfx,$tbx,$rbx,$tfz,$rfz,$tbz,$rbz);
17   my ($curphase, $recovery);
18   if ($#ARGV == 1 && "$ARGV[0]" =~ /^-rec/) {
19          $td = $ARGV[1];
# Line 57 | Line 57 | if ($windoz) {
57          $rfz = "$td\\rfz.dat";
58          $tbz = "$td\\tbz.dat";
59          $rbz = "$td\\rbz.dat";
60        $cph = "$td\\phase.txt";
60          $rmtmp = "rd /S /Q $td";
61   } else {
62          $radscn = "$td/device.rad";
# Line 80 | Line 79 | if ($windoz) {
79          $rfz = "$td/rfz.dat";
80          $tbz = "$td/tbz.dat";
81          $rbz = "$td/rbz.dat";
83        $cph = "$td/phase.txt";
82          $rmtmp = "rm -rf $td";
83   }
84   my @savedARGV = @ARGV;
# Line 189 | Line 187 | $wrapper .= " -g $mgfscn" if ( $geout );
187   my $CIEuv =     'Xi=.5141*Ri+.3239*Gi+.1620*Bi;' .
188                  'Yi=.2651*Ri+.6701*Gi+.0648*Bi;' .
189                  'Zi=.0241*Ri+.1229*Gi+.8530*Bi;' .
190 <                'den=Xi+15*Yi+3*Zi+1e-9;' .
191 <                'uprime=4*Xi/den;vprime=9*Yi/den;' ;
190 >                'den=Xi+15*Yi+3*Zi;' .
191 >                'uprime=if(Yi,4*Xi/den,4/19);' .
192 >                'vprime=if(Yi,9*Yi/den,9/19);' ;
193   my $FEPS = 1e-5;
194   my $ns = 2**$ttlog2;
195   my $nx = int(sqrt($nsamp*($dim[1]-$dim[0])/($dim[3]-$dim[2])) + 1);
# Line 204 | Line 203 | if ( !defined $recovery ) {
203          }
204          close MYAVH;
205          # Generate octree
206 <        system "oconv -w -f $radscn > $octree";
206 >        system "oconv -w $radscn > $octree";
207          die "Could not compile scene\n" if ( $? );
208          # Add MGF description if requested
209          if ( $geout ) {
# Line 212 | Line 211 | if ( !defined $recovery ) {
211                  printf MGFSCN "xf -t %.6f %.6f 0\n", -($dim[0]+$dim[1])/2, -($dim[2]+$dim[3])/2;
212                  close MGFSCN;
213                  if ( $mgfin ) {
214 +                        die "+mgf requires input file with +geom\n" if ($#ARGV < 0);
215                          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};
216                  } else {
217                          system "rad2mgf $radscn >> $mgfscn";
# Line 322 | Line 322 | sub do_ttree_dir {
322                                  qq{| rcalc -e "r1=rand(.8681*recno-.673892)" } .
323                                  qq{-e "r2=rand(-5.37138*recno+67.1737811)" } .
324                                  qq{-e "r3=rand(+3.17603772*recno+83.766771)" } .
325 <                                qq{-e "Dx=1-2*(\$1+r1)/$ns;Dy:0;Dz=sqrt(1-Dx*Dx)" } .
325 >                                qq{-e "r4=rand(-1.5839226*recno-59.82712)" } .
326 >                                qq{-e "odds(n):if(.5*n-floor(.5*n)-.25,-1,1)"} .
327 >                                qq{-e "Dx=1-(\$1+r1)/$ns2" } .
328 >                                qq{-e "Dy=min(1/$ns,sqrt(1-Dx*Dx))*odds(\$1)*r2" } .
329 >                                qq{-e "Dz=sqrt(1-Dx*Dx-Dy*Dy)" } .
330                                  qq{-e "xp=(\$3+r2)*(($dim[1]-$dim[0])/$nx)+$dim[0]" } .
331                                  qq{-e "yp=(\$2+r3)*(($dim[3]-$dim[2])/$ny)+$dim[2]" } .
332                                  qq{-e "zp=$dim[5-$forw]" -e "myDz=Dz*($forw*2-1)" } .
# Line 334 | Line 338 | sub do_ttree_dir {
338                                  qq{| rcalc -e 'r1=rand(.8681*recno-.673892)' } .
339                                  qq{-e 'r2=rand(-5.37138*recno+67.1737811)' } .
340                                  qq{-e 'r3=rand(+3.17603772*recno+83.766771)' } .
341 <                                qq{-e 'Dx=1-2*(\$1+r1)/$ns;Dy:0;Dz=sqrt(1-Dx*Dx)' } .
342 <                                qq{-e 'xp=(\$3+r2)*(($dim[1]-$dim[0])/$nx)+$dim[0]' } .
343 <                                qq{-e 'yp=(\$2+r3)*(($dim[3]-$dim[2])/$ny)+$dim[2]' } .
341 >                                qq{-e 'r4=rand(-1.5839226*recno-59.82712)' } .
342 >                                qq{-e 'odds(n):if(.5*n-floor(.5*n)-.25,-1,1)' } .
343 >                                qq{-e 'Dx=1-(\$1+r1)/$ns2' } .
344 >                                qq{-e 'Dy=min(1/$ns,sqrt(1-Dx*Dx))*odds(\$1)*r2' } .
345 >                                qq{-e 'Dz=sqrt(1-Dx*Dx-Dy*Dy)' } .
346 >                                qq{-e 'xp=(\$3+r3)*(($dim[1]-$dim[0])/$nx)+$dim[0]' } .
347 >                                qq{-e 'yp=(\$2+r4)*(($dim[3]-$dim[2])/$ny)+$dim[2]' } .
348                                  qq{-e 'zp=$dim[5-$forw]' -e 'myDz=Dz*($forw*2-1)' } .
349                                  qq{-e '\$1=xp-Dx;\$2=yp-Dy;\$3=zp-myDz' } .
350                                  qq{-e '\$4=Dx;\$5=Dy;\$6=myDz' -of } .
# Line 427 | Line 435 | sub ttree_comp {
435                  }
436          }
437          if ($pctcull >= 0) {
438 <                my $avg = ( $dorecip && "$typ" =~ /^r[fb]/ ) ? " -a" : "";
438 >                my $avg = ( $dorecip && ( $tensortree == 3 || "$typ" =~ /^r[fb]/ ) ) ? " -a" : "";
439                  my $pcull = ("$spec" eq "Visible") ? $pctcull :
440                                                       (100 - (100-$pctcull)*.25) ;
441                  if ($windoz) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines