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.49 by greg, Fri Feb 20 18:26:09 2015 UTC vs.
Revision 2.53 by greg, Wed Mar 25 19:18:28 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 204 | Line 204 | if ( $tensortree != 3 ) {      # Isotropic tensor tree is e
204          printf RADSCN "\t%f\t%f\t%f\n", $dim[0], $dim[3], $dim[5];
205          close RADSCN;
206   }
207 + # Calculate CIE (u',v') from Radiance RGB:
208 + my $CIEuv =     'Xi=.5141*Ri+.3239*Gi+.1620*Bi;' .
209 +                'Yi=.2651*Ri+.6701*Gi+.0648*Bi;' .
210 +                'Zi=.0241*Ri+.1229*Gi+.8530*Bi;' .
211 +                'den=Xi+15*Yi+3*Zi;' .
212 +                'uprime=4*Xi/den;vprime=9*Yi/den;' ;
213   # Create data segments (all the work happens here)
214   if ( $tensortree ) {
215          do_tree_bsdf();
# Line 219 | Line 225 | print "<!-- Created by: genBSDF @savedARGV -->\n";
225   system $wrapper;
226   die "Could not wrap BSDF data\n" if ( $? );
227   # Clean up temporary files and exit
228 < system $rmtmp;
228 > exec $rmtmp;
229  
230   #-------------- End of main program segment --------------#
231  
# Line 295 | Line 301 | sub ttree_out {
301                  my $ttyp = ("tb","tf")[$forw];
302                  ttree_comp($ttyp, "Visible", $transdat, ($tb,$tf)[$forw]);
303                  if ( $docolor ) {
304 <                        ttree_comp($ttyp, "CIE-X", $transdat, ($tbx,$tfx)[$forw]);
305 <                        ttree_comp($ttyp, "CIE-Z", $transdat, ($tbz,$tfz)[$forw]);
304 >                        ttree_comp($ttyp, "CIE-u", $transdat, ($tbx,$tfx)[$forw]);
305 >                        ttree_comp($ttyp, "CIE-v", $transdat, ($tbz,$tfz)[$forw]);
306                  }
307          }
308          # Output reflection
309          my $rtyp = ("rb","rf")[$forw];
310          ttree_comp($rtyp, "Visible", $refldat, ($rb,$rf)[$forw]);
311          if ( $docolor ) {
312 <                ttree_comp($rtyp, "CIE-X", $refldat, ($rbx,$rfx)[$forw]);
313 <                ttree_comp($rtyp, "CIE-Z", $refldat, ($rbz,$rfz)[$forw]);
312 >                ttree_comp($rtyp, "CIE-u", $refldat, ($rbx,$rfx)[$forw]);
313 >                ttree_comp($rtyp, "CIE-v", $refldat, ($rbz,$rfz)[$forw]);
314          }
315   }       # end of ttree_out()
316  
# Line 318 | Line 324 | sub ttree_comp {
324          if ($windoz) {
325                  if ("$spec" eq "Visible") {
326                          $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
327 <                                q{-e "$1=(0.265*$1+0.670*$2+0.065*$3)/Omega"};
328 <                } elsif ("$spec" eq "CIE-X") {
327 >                                q{-e "Ri=$1;Gi=$2;Bi=$3" } .
328 >                                qq{-e "$CIEuv" } .
329 >                                q{-e "$1=Yi/Omega"};
330 >                } elsif ("$spec" eq "CIE-u") {
331                          $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
332 <                                q{-e "$1=(0.514*$1+0.324*$2+0.162*$3)/Omega"};
333 <                } elsif ("$spec" eq "CIE-Z") {
332 >                                q{-e "Ri=$1;Gi=$2;Bi=$3" } .
333 >                                qq{-e "$CIEuv" } .
334 >                                q{-e "$1=uprime/Omega"};
335 >                } elsif ("$spec" eq "CIE-v") {
336                          $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
337 <                                q{-e "$1=(0.024*$1+0.123*$2+0.853*$3)/Omega"};
337 >                                q{-e "Ri=$1;Gi=$2;Bi=$3" } .
338 >                                qq{-e "$CIEuv" } .
339 >                                q{-e "$1=vprime/Omega"};
340                  }
341          } else {
342                  if ("$spec" eq "Visible") {
343                          $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
344 <                                q{-e '$1=(0.265*$1+0.670*$2+0.065*$3)/Omega'};
345 <                } elsif ("$spec" eq "CIE-X") {
344 >                                q{-e 'Ri=$1;Gi=$2;Bi=$3' } .
345 >                                "-e '$CIEuv' " .
346 >                                q{-e '$1=Yi/Omega'};
347 >                } elsif ("$spec" eq "CIE-u") {
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") {
349 >                                q{-e 'Ri=$1;Gi=$2;Bi=$3' } .
350 >                                "-e '$CIEuv' " .
351 >                                q{-e '$1=uprime/Omega'};
352 >                } elsif ("$spec" eq "CIE-v") {
353                          $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
354 <                                q{-e '$1=(0.024*$1+0.123*$2+0.853*$3)/Omega'};
354 >                                q{-e 'Ri=$1;Gi=$2;Bi=$3' } .
355 >                                "-e '$CIEuv' " .
356 >                                q{-e '$1=vprime/Omega'};
357                  }
358          }
359          if ($pctcull >= 0) {
360                  my $avg = ( "$typ" =~ /^r[fb]/ ) ? " -a" : "";
361 +                my $pcull = ("$spec" eq "Visible") ? $pctcull :
362 +                                                     (100 - (100-$pctcull)/3) ;
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 371 | Line 391 | sub ttree_comp {
391                  close DATOUT;
392          }
393          if ( "$spec" ne "$curspec" ) {
394 <                $wrapper .= " -s $spec"
394 >                $wrapper .= " -s $spec";
395                  $curspec = $spec;
396          }
397          $wrapper .= " -$typ $dest";
# Line 440 | Line 460 | sub matrix_comp {
460          } elsif ("$spec" eq "CIE-Z") {
461                  $cmd .= " -c 0.024 0.123 0.853";
462          }
463 <        $cmd .= " $src | getinfo -";
463 >        $cmd .= " $src | rcollate -ho -oc 145";
464          # print STDERR "Running: $cmd\n";
465          system "$cmd > $dest";
466          die "Failure running rttree_reduce" if ( $? );
467          if ( "$spec" ne "$curspec" ) {
468 <                $wrapper .= " -s $spec"
468 >                $wrapper .= " -s $spec";
469                  $curspec = $spec;
470          }
471          $wrapper .= " -$typ $dest";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines