#!/usr/bin/perl -w
# run a bunch of renders to test Radiance's "-aa 0" option

$final = 256;
$rad = 0.7;

@abval = ('1', '2', '3');
@abval = ('2');

#@adval = ('4', '16', '64', '256');
@adval = ('4', '16', '64');

#@multiplier = ('1', '2', '3', '4', '6', '8', '12');
@multiplier = ('6', '8', '12');

open(HTML,"> temp.html");

foreach $ab (@abval) {

   print HTML "<hr>\n";
   print HTML "<table>\n";
   print HTML "<h3>Using -ab ${ab}</h3>\n";
   print HTML "<tr>\n";
   print HTML "<td> </td>\n";
   foreach $ad (@adval) {
      print HTML "<td>-ad ${ad}</td>\n";
   }
   print HTML "</tr>\n";

   foreach $mult (@multiplier) {

      print HTML "<tr>\n";
      print HTML "<td>${mult}x final resolution</td>\n";

      foreach $ad (@adval) {

         # first, render the thing
         $size = $mult * $final;
         $command = "time rpict -vp 3.6 2 1.5 -vd -3.6 -2 -1.1 -vh 25 -vv 25 -ds 0.1 -dj 0.6 -ps 1 -aa 0 -ab ${ab} -ad ${ad} -x ${size} -y ${size} scene.oct > raw.pic";
         print "$command \n";
         system $command;

         $filtered = "img_ab${ab}_${mult}x_ad${ad}.pic";
         $filtpng = "img_ab${ab}_${mult}x_ad${ad}.png";
         $command = "time pfilt -1 -e -5 -x /${mult} -y /${mult} -r ${rad} raw.pic > ${filtered}";
         print "$command \n";
         system $command;
         $command = "ra_ppm ${filtered} | pnmtopng > ${filtpng}";
         print "$command \n";
         system $command;

         print HTML "<td><img src=\"${filtpng}\"><br>3s, 11111 bytes</td>\n";
         print "\n";
      }
      print HTML "</tr>\n";
   }
   print HTML "</table>\n";

   print "\n\n";
}

close(HTML);
exit;
