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.51 by greg, Thu Mar 12 13:24:41 2015 UTC vs.
Revision 2.55 by greg, Fri Mar 27 18:58:06 2015 UTC

# Line 66 | Line 66 | if ($windoz) {
66          $rmtmp = "rm -rf $td";
67   }
68   my @savedARGV = @ARGV;
69 < my $rfluxmtx = "rfluxmtx -v -ab 5 -ad 700 -lw 3e-6";
69 > my $rfluxmtx = "rfluxmtx -ab 5 -ad 700 -lw 3e-6";
70   my $wrapper = "wrapBSDF";
71   my $tensortree = 0;
72   my $ttlog2 = 4;
# 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 176 | Line 179 | my $ny = int($nsamp/$nx + 1);
179   $nsamp = $nx * $ny;
180   my $ns = 2**$ttlog2;
181   open(RADSCN, "> $receivers");
182 < print RADSCN '#@rfluxmtx ' . ($tensortree ? "h=sc$ns\n" : "h=kf\n");
182 > print RADSCN '#@rfluxmtx ' . ($tensortree ? "h=+sc$ns\n" : "h=+kf\n");
183   print RADSCN '#@rfluxmtx ' . "u=Y o=$facedat\n\n";
184   print RADSCN "void glow receiver_face\n0\n0\n4 1 1 1 0\n\n";
185   print RADSCN "receiver_face source f_receiver\n0\n0\n4 0 0 1 180\n\n";
186 + print RADSCN '#@rfluxmtx ' . ($tensortree ? "h=-sc$ns\n" : "h=-kf\n");
187   print RADSCN '#@rfluxmtx ' . "u=Y o=$behinddat\n\n";
188   print RADSCN "void glow receiver_behind\n0\n0\n4 1 1 1 0\n\n";
189   print RADSCN "receiver_behind source b_receiver\n0\n0\n4 0 0 -1 180\n";
# Line 188 | Line 192 | close RADSCN;
192   $rfluxmtx .= " -n $nproc -c $nsamp";
193   if ( $tensortree != 3 ) {       # Isotropic tensor tree is exception
194          open (RADSCN, "> $fsender");
195 <        print RADSCN '#@rfluxmtx u=Y ' . ($tensortree ? "h=sc$ns\n\n" : "h=kf\n\n");
195 >        print RADSCN '#@rfluxmtx u=Y ' . ($tensortree ? "h=+sc$ns\n\n" : "h=+kf\n\n");
196          print RADSCN "void polygon fwd_sender\n0\n0\n12\n";
197          printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[2], $dim[4];
198          printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[3], $dim[4];
# Line 196 | Line 200 | if ( $tensortree != 3 ) {      # Isotropic tensor tree is e
200          printf RADSCN "\t%f\t%f\t%f\n", $dim[1], $dim[2], $dim[4];
201          close RADSCN;
202          open (RADSCN, "> $bsender");
203 <        print RADSCN '#@rfluxmtx u=Y ' . ($tensortree ? "h=sc$ns\n\n" : "h=kf\n\n");
204 <        print RADSCN "void polygon fwd_sender\n0\n0\n12\n";
203 >        print RADSCN '#@rfluxmtx u=Y ' . ($tensortree ? "h=-sc$ns\n\n" : "h=-kf\n\n");
204 >        print RADSCN "void polygon bwd_sender\n0\n0\n12\n";
205          printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[2], $dim[5];
206          printf RADSCN "\t%f\t%f\t%f\n", $dim[1], $dim[2], $dim[5];
207          printf RADSCN "\t%f\t%f\t%f\n", $dim[1], $dim[3], $dim[5];
208          printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[3], $dim[5];
209          close RADSCN;
210   }
211 + # Calculate CIE (u',v') from Radiance RGB:
212 + my $CIEuv =     'Xi=.5141*Ri+.3239*Gi+.1620*Bi;' .
213 +                'Yi=.2651*Ri+.6701*Gi+.0648*Bi;' .
214 +                'Zi=.0241*Ri+.1229*Gi+.8530*Bi;' .
215 +                'den=Xi+15*Yi+3*Zi;' .
216 +                'uprime=4*Xi/den;vprime=9*Yi/den;' ;
217   # Create data segments (all the work happens here)
218   if ( $tensortree ) {
219          do_tree_bsdf();
# Line 219 | Line 229 | print "<!-- Created by: genBSDF @savedARGV -->\n";
229   system $wrapper;
230   die "Could not wrap BSDF data\n" if ( $? );
231   # Clean up temporary files and exit
232 < system $rmtmp;
232 > exec $rmtmp;
233  
234   #-------------- End of main program segment --------------#
235  
# Line 295 | Line 305 | sub ttree_out {
305                  my $ttyp = ("tb","tf")[$forw];
306                  ttree_comp($ttyp, "Visible", $transdat, ($tb,$tf)[$forw]);
307                  if ( $docolor ) {
308 <                        ttree_comp($ttyp, "CIE-X", $transdat, ($tbx,$tfx)[$forw]);
309 <                        ttree_comp($ttyp, "CIE-Z", $transdat, ($tbz,$tfz)[$forw]);
308 >                        ttree_comp($ttyp, "CIE-u", $transdat, ($tbx,$tfx)[$forw]);
309 >                        ttree_comp($ttyp, "CIE-v", $transdat, ($tbz,$tfz)[$forw]);
310                  }
311          }
312          # Output reflection
313          my $rtyp = ("rb","rf")[$forw];
314          ttree_comp($rtyp, "Visible", $refldat, ($rb,$rf)[$forw]);
315          if ( $docolor ) {
316 <                ttree_comp($rtyp, "CIE-X", $refldat, ($rbx,$rfx)[$forw]);
317 <                ttree_comp($rtyp, "CIE-Z", $refldat, ($rbz,$rfz)[$forw]);
316 >                ttree_comp($rtyp, "CIE-u", $refldat, ($rbx,$rfx)[$forw]);
317 >                ttree_comp($rtyp, "CIE-v", $refldat, ($rbz,$rfz)[$forw]);
318          }
319   }       # end of ttree_out()
320  
# Line 318 | Line 328 | sub ttree_comp {
328          if ($windoz) {
329                  if ("$spec" eq "Visible") {
330                          $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
331 <                                q{-e "$1=(0.265*$1+0.670*$2+0.065*$3)/Omega"};
332 <                } elsif ("$spec" eq "CIE-X") {
333 <                        $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
334 <                                q{-e "$1=(0.514*$1+0.324*$2+0.162*$3)/Omega"};
335 <                } elsif ("$spec" eq "CIE-Z") {
336 <                        $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
337 <                                q{-e "$1=(0.024*$1+0.123*$2+0.853*$3)/Omega"};
331 >                                q{-e "Ri=$1;Gi=$2;Bi=$3" } .
332 >                                qq{-e "$CIEuv" } .
333 >                                q{-e "$1=Yi/Omega"};
334 >                } elsif ("$spec" eq "CIE-u") {
335 >                        $cmd = q{rcalc -e "Ri=$1;Gi=$2;Bi=$3" } .
336 >                                qq{-e "$CIEuv" } .
337 >                                q{-e "$1=uprime"};
338 >                } elsif ("$spec" eq "CIE-v") {
339 >                        $cmd = q{rcalc -e "Ri=$1;Gi=$2;Bi=$3" } .
340 >                                qq{-e "$CIEuv" } .
341 >                                q{-e "$1=vprime"};
342                  }
343          } else {
344                  if ("$spec" eq "Visible") {
345                          $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
346 <                                q{-e '$1=(0.265*$1+0.670*$2+0.065*$3)/Omega'};
347 <                } elsif ("$spec" eq "CIE-X") {
348 <                        $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
349 <                                q{-e '$1=(0.514*$1+0.324*$2+0.162*$3)/Omega'};
350 <                } elsif ("$spec" eq "CIE-Z") {
351 <                        $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
352 <                                q{-e '$1=(0.024*$1+0.123*$2+0.853*$3)/Omega'};
346 >                                q{-e 'Ri=$1;Gi=$2;Bi=$3' } .
347 >                                "-e '$CIEuv' " .
348 >                                q{-e '$1=Yi/Omega'};
349 >                } elsif ("$spec" eq "CIE-u") {
350 >                        $cmd = q{rcalc -if3 -e 'Ri=$1;Gi=$2;Bi=$3' } .
351 >                                "-e '$CIEuv' " .
352 >                                q{-e '$1=uprime'};
353 >                } elsif ("$spec" eq "CIE-v") {
354 >                        $cmd = q{rcalc -if3 -e 'Ri=$1;Gi=$2;Bi=$3' } .
355 >                                "-e '$CIEuv' " .
356 >                                q{-e '$1=vprime'};
357                  }
358          }
359          if ($pctcull >= 0) {
360                  my $avg = ( "$typ" =~ /^r[fb]/ ) ? " -a" : "";
361 +                my $pcull = ("$spec" eq "Visible") ? $pctcull :
362 +                                                     (100 - (100-$pctcull)*.25) ;
363                  if ($windoz) {
364                          $cmd = "rcollate -ho -oc 1 $src | " .
365                                          $cmd .
366 <                                        " | rttree_reduce$avg -h -fa -t $pctcull -r $tensortree -g $ttlog2";
366 >                                        " | rttree_reduce$avg -h -fa -t $pcull -r $tensortree -g $ttlog2";
367                  } else {
368                          $cmd .= " -of $src " .
369 <                                        "| rttree_reduce$avg -h -ff -t $pctcull -r $tensortree -g $ttlog2";
369 >                                        "| rttree_reduce$avg -h -ff -t $pcull -r $tensortree -g $ttlog2";
370                  }
371                  # print STDERR "Running: $cmd\n";
372                  system "$cmd > $dest";
# Line 434 | Line 454 | sub matrix_comp {
454          my $dest = shift;
455          my $cmd = "rmtxop -fa -t";
456          if ("$spec" eq "Visible") {
457 <                $cmd .= " -c 0.265 0.670 0.065";
457 >                $cmd .= " -c 0.2651 0.6701 0.0648";
458          } elsif ("$spec" eq "CIE-X") {
459 <                $cmd .= " -c 0.514 0.324 0.162";
459 >                $cmd .= " -c 0.5141 0.3239 0.1620";
460          } elsif ("$spec" eq "CIE-Z") {
461 <                $cmd .= " -c 0.024 0.123 0.853";
461 >                $cmd .= " -c 0.0241 0.1229 0.8530";
462          }
463 <        $cmd .= " $src | rcollate -ho";
463 >        $cmd .= " $src | rcollate -ho -oc 145";
464          # print STDERR "Running: $cmd\n";
465          system "$cmd > $dest";
466          die "Failure running rttree_reduce" if ( $? );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines