#!/usr/bin/perl -w
# run a bunch of renders to test Radiance and pfilt's capabilities

$final = 256;
@radius = ('0.5', '0.75', '1.0', '1.25', '1.5');

# for each multiple of 256
for ($mult=1; $mult<6; $mult++) {

   # first, render the thing
   $raw_file = "raw_${mult}.pic";
   $size = $mult * $final;
   $command = "time rpict -vp 10 -1 1 -vd -10 1 -1 -ab 2 -ar 128 -ad 512 -as 256 -af sphere.amb -t 60 -x ${size} -y ${size} sphere.oct > ${raw_file}";
   print "$command \n";
   system $command;

   # then, use the box filter to reduce in size
   $filtered = "img_${mult}_box.pic";
   $filtpng = "img_${mult}_box.png";
   $command = "time pfilt -1 -e +8 -x /${mult} -y /${mult} raw_${mult}.pic > ${filtered}";
   print "$command \n";
   system $command;
   $command = "ra_ppm ${filtered} | pnmtopng > ${filtpng}";
   print "$command \n";
   system $command;
   print "\n";

   foreach $rad (@radius) {
      $textrad = $rad;
      $textrad =~ s/\./p/g;
      # print "$rad $textrad \n";
      $filtered = "img_${mult}_${textrad}.pic";
      $filtpng = "img_${mult}_${textrad}.png";
      $command = "time pfilt -1 -e +8 -x /${mult} -y /${mult} -r ${rad} raw_${mult}.pic > ${filtered}";
      print "$command \n";
      system $command;
      $command = "ra_ppm ${filtered} | pnmtopng > ${filtpng}";
      print "$command \n";
      system $command;
      print "\n";
   }

   print "\n\n";
}

exit;
