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.53 by greg, Wed Mar 25 19:18:28 2015 UTC vs.
Revision 2.58 by greg, Fri May 29 07:22:33 2015 UTC

# Line 9 | Line 9 | use strict;
9   my $windoz = ($^O eq "MSWin32" or $^O eq "MSWin64");
10   use File::Temp qw/ :mktemp  /;
11   sub userror {
12 <        print STDERR "Usage: genBSDF [-n Nproc][-c Nsamp][-W][-t{3|4} Nlog2][-r \"ropts\"][-f \"x=string;y=string\"][-dim xmin xmax ymin ymax zmin zmax][{+|-}C][{+|-}f][{+|-}b][{+|-}mgf][{+|-}geom units] [input ..]\n";
12 >        print STDERR "Usage: genBSDF [-n Nproc][-c Nsamp][-W][-t{3|4} Nlog2][-r \"ropts\"][-s \"x=string;y=string\"][-dim xmin xmax ymin ymax zmin zmax][{+|-}C][{+|-}f][{+|-}b][{+|-}mgf][{+|-}geom units] [input ..]\n";
13          exit 1;
14   }
15   my ($td,$radscn,$mgfscn,$octree,$fsender,$bsender,$receivers,$facedat,$behinddat,$rmtmp);
# Line 104 | Line 104 | while ($#ARGV >= 0) {
104          } elsif ("$ARGV[0]" eq "-t") {
105                  # Use value < 0 for rttree_reduce bypass
106                  $pctcull = $ARGV[1];
107 +                if ($pctcull >= 100) {
108 +                        die "Illegal -t culling percentage, must be < 100\n";
109 +                }
110                  shift @ARGV;
111          } elsif ("$ARGV[0]" =~ /^-t[34]$/) {
112                  $tensortree = substr($ARGV[0], 2, 1);
113                  $ttlog2 = $ARGV[1];
114                  shift @ARGV;
115 <        } elsif ("$ARGV[0]" eq "-f") {
115 >        } elsif ("$ARGV[0]" eq "-s") {
116                  $wrapper .= " -f \"$ARGV[1]\"";
117                  shift @ARGV;
118          } elsif ("$ARGV[0]" eq "-W") {
# Line 171 | Line 174 | if ( $geout ) {
174          $wrapper .= " -g $mgfscn";
175   }
176   # Create receiver & sender surfaces (rectangular)
177 + my $FEPS = 1e-5;
178   my $nx = int(sqrt($nsamp*($dim[1]-$dim[0])/($dim[3]-$dim[2])) + 1);
179   my $ny = int($nsamp/$nx + 1);
180   $nsamp = $nx * $ny;
181   my $ns = 2**$ttlog2;
182   open(RADSCN, "> $receivers");
183 < print RADSCN '#@rfluxmtx ' . ($tensortree ? "h=sc$ns\n" : "h=kf\n");
184 < print RADSCN '#@rfluxmtx ' . "u=Y o=$facedat\n\n";
183 > print RADSCN '#@rfluxmtx ' . ($tensortree ? "h=-sc$ns\n" : "h=-kf\n");
184 > print RADSCN '#@rfluxmtx ' . "u=-Y o=$facedat\n\n";
185   print RADSCN "void glow receiver_face\n0\n0\n4 1 1 1 0\n\n";
186   print RADSCN "receiver_face source f_receiver\n0\n0\n4 0 0 1 180\n\n";
187 < print RADSCN '#@rfluxmtx ' . "u=Y o=$behinddat\n\n";
187 > print RADSCN '#@rfluxmtx ' . ($tensortree ? "h=+sc$ns\n" : "h=+kf\n");
188 > print RADSCN '#@rfluxmtx ' . "u=-Y o=$behinddat\n\n";
189   print RADSCN "void glow receiver_behind\n0\n0\n4 1 1 1 0\n\n";
190   print RADSCN "receiver_behind source b_receiver\n0\n0\n4 0 0 -1 180\n";
191   close RADSCN;
# Line 188 | Line 193 | close RADSCN;
193   $rfluxmtx .= " -n $nproc -c $nsamp";
194   if ( $tensortree != 3 ) {       # Isotropic tensor tree is exception
195          open (RADSCN, "> $fsender");
196 <        print RADSCN '#@rfluxmtx u=Y ' . ($tensortree ? "h=sc$ns\n\n" : "h=kf\n\n");
196 >        print RADSCN '#@rfluxmtx u=-Y ' . ($tensortree ? "h=-sc$ns\n\n" : "h=-kf\n\n");
197          print RADSCN "void polygon fwd_sender\n0\n0\n12\n";
198 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[2], $dim[4];
199 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[3], $dim[4];
200 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[1], $dim[3], $dim[4];
201 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[1], $dim[2], $dim[4];
198 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[0], $dim[2], $dim[4]-$FEPS;
199 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[0], $dim[3], $dim[4]-$FEPS;
200 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[1], $dim[3], $dim[4]-$FEPS;
201 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[1], $dim[2], $dim[4]-$FEPS;
202          close RADSCN;
203          open (RADSCN, "> $bsender");
204 <        print RADSCN '#@rfluxmtx u=Y ' . ($tensortree ? "h=sc$ns\n\n" : "h=kf\n\n");
205 <        print RADSCN "void polygon fwd_sender\n0\n0\n12\n";
206 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[2], $dim[5];
207 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[1], $dim[2], $dim[5];
208 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[1], $dim[3], $dim[5];
209 <        printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[3], $dim[5];
204 >        print RADSCN '#@rfluxmtx u=-Y ' . ($tensortree ? "h=+sc$ns\n\n" : "h=+kf\n\n");
205 >        print RADSCN "void polygon bwd_sender\n0\n0\n12\n";
206 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[0], $dim[2], $dim[5]+$FEPS;
207 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[1], $dim[2], $dim[5]+$FEPS;
208 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[1], $dim[3], $dim[5]+$FEPS;
209 >        printf RADSCN "\t%e\t%e\t%e\n", $dim[0], $dim[3], $dim[5]+$FEPS;
210          close RADSCN;
211   }
212   # Calculate CIE (u',v') from Radiance RGB:
# Line 220 | Line 225 | if ( $tensortree ) {
225   my $old_fh = select(STDOUT);
226   $| = 1;
227   select($old_fh);
228 + print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
229   print "<!-- Created by: genBSDF @savedARGV -->\n";
230   # print STDERR "Running: $wrapper\n";
231   system $wrapper;
# Line 328 | Line 334 | sub ttree_comp {
334                                  qq{-e "$CIEuv" } .
335                                  q{-e "$1=Yi/Omega"};
336                  } elsif ("$spec" eq "CIE-u") {
337 <                        $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
332 <                                q{-e "Ri=$1;Gi=$2;Bi=$3" } .
337 >                        $cmd = q{rcalc -e "Ri=$1;Gi=$2;Bi=$3" } .
338                                  qq{-e "$CIEuv" } .
339 <                                q{-e "$1=uprime/Omega"};
339 >                                q{-e "$1=uprime"};
340                  } elsif ("$spec" eq "CIE-v") {
341 <                        $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
337 <                                q{-e "Ri=$1;Gi=$2;Bi=$3" } .
341 >                        $cmd = q{rcalc -e "Ri=$1;Gi=$2;Bi=$3" } .
342                                  qq{-e "$CIEuv" } .
343 <                                q{-e "$1=vprime/Omega"};
343 >                                q{-e "$1=vprime"};
344                  }
345          } else {
346                  if ("$spec" eq "Visible") {
# Line 345 | Line 349 | sub ttree_comp {
349                                  "-e '$CIEuv' " .
350                                  q{-e '$1=Yi/Omega'};
351                  } elsif ("$spec" eq "CIE-u") {
352 <                        $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
349 <                                q{-e 'Ri=$1;Gi=$2;Bi=$3' } .
352 >                        $cmd = q{rcalc -if3 -e 'Ri=$1;Gi=$2;Bi=$3' } .
353                                  "-e '$CIEuv' " .
354 <                                q{-e '$1=uprime/Omega'};
354 >                                q{-e '$1=uprime'};
355                  } elsif ("$spec" eq "CIE-v") {
356 <                        $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
354 <                                q{-e 'Ri=$1;Gi=$2;Bi=$3' } .
356 >                        $cmd = q{rcalc -if3 -e 'Ri=$1;Gi=$2;Bi=$3' } .
357                                  "-e '$CIEuv' " .
358 <                                q{-e '$1=vprime/Omega'};
358 >                                q{-e '$1=vprime'};
359                  }
360          }
361          if ($pctcull >= 0) {
362                  my $avg = ( "$typ" =~ /^r[fb]/ ) ? " -a" : "";
363                  my $pcull = ("$spec" eq "Visible") ? $pctcull :
364 <                                                     (100 - (100-$pctcull)/3) ;
364 >                                                     (100 - (100-$pctcull)*.25) ;
365                  if ($windoz) {
366                          $cmd = "rcollate -ho -oc 1 $src | " .
367                                          $cmd .
# Line 454 | Line 456 | sub matrix_comp {
456          my $dest = shift;
457          my $cmd = "rmtxop -fa -t";
458          if ("$spec" eq "Visible") {
459 <                $cmd .= " -c 0.265 0.670 0.065";
459 >                $cmd .= " -c 0.2651 0.6701 0.0648";
460          } elsif ("$spec" eq "CIE-X") {
461 <                $cmd .= " -c 0.514 0.324 0.162";
461 >                $cmd .= " -c 0.5141 0.3239 0.1620";
462          } elsif ("$spec" eq "CIE-Z") {
463 <                $cmd .= " -c 0.024 0.123 0.853";
463 >                $cmd .= " -c 0.0241 0.1229 0.8530";
464          }
465          $cmd .= " $src | rcollate -ho -oc 145";
466          # print STDERR "Running: $cmd\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines