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.50 by greg, Wed Mar 4 17:42:54 2015 UTC vs.
Revision 2.54 by greg, Wed Mar 25 22:50:48 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") {
329 <                        $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
330 <                                q{-e "$1=(0.514*$1+0.324*$2+0.162*$3)/Omega"};
331 <                } elsif ("$spec" eq "CIE-Z") {
332 <                        $cmd = qq{rcalc -e "Omega:PI/($ns*$ns)" } .
333 <                                q{-e "$1=(0.024*$1+0.123*$2+0.853*$3)/Omega"};
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 = q{rcalc -e "Ri=$1;Gi=$2;Bi=$3" } .
332 >                                qq{-e "$CIEuv" } .
333 >                                q{-e "$1=uprime"};
334 >                } elsif ("$spec" eq "CIE-v") {
335 >                        $cmd = q{rcalc -e "Ri=$1;Gi=$2;Bi=$3" } .
336 >                                qq{-e "$CIEuv" } .
337 >                                q{-e "$1=vprime"};
338                  }
339          } else {
340                  if ("$spec" eq "Visible") {
341                          $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
342 <                                q{-e '$1=(0.265*$1+0.670*$2+0.065*$3)/Omega'};
343 <                } elsif ("$spec" eq "CIE-X") {
344 <                        $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
345 <                                q{-e '$1=(0.514*$1+0.324*$2+0.162*$3)/Omega'};
346 <                } elsif ("$spec" eq "CIE-Z") {
347 <                        $cmd = "rcalc -if3 -e 'Omega:PI/($ns*$ns)' " .
348 <                                q{-e '$1=(0.024*$1+0.123*$2+0.853*$3)/Omega'};
342 >                                q{-e 'Ri=$1;Gi=$2;Bi=$3' } .
343 >                                "-e '$CIEuv' " .
344 >                                q{-e '$1=Yi/Omega'};
345 >                } elsif ("$spec" eq "CIE-u") {
346 >                        $cmd = q{rcalc -if3 -e 'Ri=$1;Gi=$2;Bi=$3' } .
347 >                                "-e '$CIEuv' " .
348 >                                q{-e '$1=uprime'};
349 >                } elsif ("$spec" eq "CIE-v") {
350 >                        $cmd = q{rcalc -if3 -e 'Ri=$1;Gi=$2;Bi=$3' } .
351 >                                "-e '$CIEuv' " .
352 >                                q{-e '$1=vprime'};
353                  }
354          }
355          if ($pctcull >= 0) {
356                  my $avg = ( "$typ" =~ /^r[fb]/ ) ? " -a" : "";
357 +                my $pcull = ("$spec" eq "Visible") ? $pctcull :
358 +                                                     (100 - (100-$pctcull)/3) ;
359                  if ($windoz) {
360                          $cmd = "rcollate -ho -oc 1 $src | " .
361                                          $cmd .
362 <                                        " | rttree_reduce$avg -h -fa -t $pctcull -r $tensortree -g $ttlog2";
362 >                                        " | rttree_reduce$avg -h -fa -t $pcull -r $tensortree -g $ttlog2";
363                  } else {
364                          $cmd .= " -of $src " .
365 <                                        "| rttree_reduce$avg -h -ff -t $pctcull -r $tensortree -g $ttlog2";
365 >                                        "| rttree_reduce$avg -h -ff -t $pcull -r $tensortree -g $ttlog2";
366                  }
367                  # print STDERR "Running: $cmd\n";
368                  system "$cmd > $dest";
# Line 371 | Line 387 | sub ttree_comp {
387                  close DATOUT;
388          }
389          if ( "$spec" ne "$curspec" ) {
390 <                $wrapper .= " -s $spec"
390 >                $wrapper .= " -s $spec";
391                  $curspec = $spec;
392          }
393          $wrapper .= " -$typ $dest";
# Line 440 | Line 456 | sub matrix_comp {
456          } elsif ("$spec" eq "CIE-Z") {
457                  $cmd .= " -c 0.024 0.123 0.853";
458          }
459 <        $cmd .= " $src | rcollate -ho";
459 >        $cmd .= " $src | rcollate -ho -oc 145";
460          # print STDERR "Running: $cmd\n";
461          system "$cmd > $dest";
462          die "Failure running rttree_reduce" if ( $? );
463          if ( "$spec" ne "$curspec" ) {
464 <                $wrapper .= " -s $spec"
464 >                $wrapper .= " -s $spec";
465                  $curspec = $spec;
466          }
467          $wrapper .= " -$typ $dest";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines