Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1631 - trunk/Engine/ImageTraversers


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r1631 - trunk/Engine/ImageTraversers
  • Date: Tue, 14 Aug 2007 15:53:22 -0600 (MDT)

Author: boulos
Date: Tue Aug 14 15:53:22 2007
New Revision: 1631

Modified:
   trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc
   trunk/Engine/ImageTraversers/DeadlineImageTraverser.h
Log:
Adding ability to refine to more than RayPacket::MaxSize
samples per pixel.  The maximum is now 1024 spp ;)



Modified: trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc
==============================================================================
--- trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc      (original)
+++ trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc      Tue Aug 14 
15:53:22 2007
@@ -245,7 +245,7 @@
       converged = true;
       double EndTime = CPUTime::currentSeconds();
       double total_time = EndTime - StartFrameTime;
-      cerr << "Took " << total_time << " seconds to refine to 
"<<Fragment::MaxSize<<" spp" << endl;
+      cerr << "Took " << total_time << " seconds to refine to "<< (4 << 
kNumJitterLevels) <<" spp" << endl;
     }
   }
 }
@@ -355,9 +355,12 @@
 
   while(CPUTime::currentSeconds() < frameEnd){
     Tile* tile = popFromQueue(static_cast<size_t>(context.proc));
+
     if(!tile)
       continue;
 
+    //cerr << "tile->priority = " << tile->priority << endl;
+
     childtiles.clear();
 
     float newxmag = tile->xmag/xrefinementRatio;
@@ -373,88 +376,119 @@
       // TODO(boulos): Can we do some other number of samples?
       int samples_per_pixel = x_samples * y_samples;
 
+      if (samples_per_pixel > 1024)
+        continue;
+      // NOTE(boulos): We know that we don't just stop anymore due
+      // to super sampling
+      JitterSampler* jitter_sampler = NULL;
+      switch (samples_per_pixel) {
+      case 4:
+        //cerr << "Using a 4 spp sampler" << endl;
+        jitter_sampler = jitterSamplers[0];
+        break;
+      case 16:
+        //cerr << "Using a 16 spp sampler" << endl;
+        jitter_sampler = jitterSamplers[1];
+        break;
+      case 64:
+        //cerr << "Using a 64 spp sampler" << endl;
+        jitter_sampler = jitterSamplers[2];
+        break;
+      case 256:
+        //cerr << "Using a 256 spp sampler" << endl;
+        jitter_sampler = jitterSamplers[3];
+        break;
+      case 1024:
+        jitter_sampler = jitterSamplers[4];
+      default:
+        throw SCIRun::InternalError("Expected either 4, 16, 64, 256, or 1024 
spp", __FILE__, __LINE__);
+        break;
+      }
+
       int xs = static_cast<int>(xpacketsize * newxmag);
       int ys = static_cast<int>(ypacketsize * newymag);
       // We might be asking for more samples than we can fit in a
       // packet.
-      if (xs < 1 || ys < 1)
-        continue;
-
-      for(int y = tile->ystart; y < tile->yend; y += ys){
-        for(int x = tile->xstart; x < tile->xend; x += xs){
-          int xend = x + xs;
-          if(xend > tile->xend)
-            xend = tile->xend;
-          int yend = y + ys;
-          if(yend > tile->yend)
-            yend = tile->yend;
+      if (xs < 1 || ys < 1) {
+        // Handle multiple packets per pixel.
+        cerr << "Multiple packets per pixel (spp = " << samples_per_pixel << 
", newxmag = " << newxmag << ")\n";
+        if (xs != ys) {
+          throw SCIRun::InternalError("Don't handle non-square refinement 
yet",
+                                      __FILE__, __LINE__);
+        }
 
-          // NOTE(boulos): This logic is now slightly different as we
-          // are going to make smaller fragments.  This makes it so we
-          // don't need to change the render fragment logic (a single
-          // fragment will now just have many samples) so the fragment
-          // size will be smaller than before
-          Fragment frag(Fragment::SquareShape, Fragment::ConstantEye);
-          frag.setPixelSize(1, 1);
-          int idx = 0;
-          for (int j = y; j < yend; j++) {
-            for (int i = x; i < xend; i++) {
-              frag.pixel[0][idx] = i;
-              frag.pixel[1][idx] = j;
-              frag.whichEye[idx] = 0;
-              idx++;
+        Fragment frag(Fragment::SquareShape, Fragment::ConstantEye);
+        frag.setPixelSize(1, 1);
+        frag.pixel[0][0] = tile->xstart;
+        frag.pixel[1][0] = tile->ystart;
+        frag.whichEye[0] = 0;
+        frag.setSize(1);
+        jitter_sampler->renderFragment(context, frag);
+
+        //Tile* childtile = new Tile;
+        ASSERT(context.proc < DeadlineImageTraverser::kMaxThreads);
+        Tile* childtile = tile_pools[context.proc].getItem();
+        childtile->xstart = tile->xstart;
+        childtile->xend   = tile->xstart;
+        childtile->ystart = tile->ystart;
+        childtile->yend   = tile->ystart;
+        childtile->xmag = newxmag;
+        childtile->ymag = newymag;
+        computePriority(childtile, frag);
+        childtiles.push_back(childtile);
+        image->set(frag);
+      } else {
+        for(int y = tile->ystart; y < tile->yend; y += ys){
+          for(int x = tile->xstart; x < tile->xend; x += xs){
+            int xend = x + xs;
+            if(xend > tile->xend)
+              xend = tile->xend;
+            int yend = y + ys;
+            if(yend > tile->yend)
+              yend = tile->yend;
+
+            // NOTE(boulos): This logic is now slightly different as we
+            // are going to make smaller fragments.  This makes it so we
+            // don't need to change the render fragment logic (a single
+            // fragment will now just have many samples) so the fragment
+            // size will be smaller than before
+            Fragment frag(Fragment::SquareShape, Fragment::ConstantEye);
+            frag.setPixelSize(1, 1);
+            int idx = 0;
+            for (int j = y; j < yend; j++) {
+              for (int i = x; i < xend; i++) {
+                frag.pixel[0][idx] = i;
+                frag.pixel[1][idx] = j;
+                frag.whichEye[idx] = 0;
+                idx++;
+              }
             }
-          }
-          frag.setSize(idx);
+            frag.setSize(idx);
 
-          // NOTE(boulos): We know that we don't just stop anymore due
-          // to super sampling
-          JitterSampler* jitter_sampler = NULL;
-          switch (samples_per_pixel) {
-          case 4:
-            //cerr << "Using a 4 spp sampler" << endl;
-            jitter_sampler = jitterSamplers[0];
-            break;
-          case 16:
-            //cerr << "Using a 16 spp sampler" << endl;
-            jitter_sampler = jitterSamplers[1];
-            break;
-          case 64:
-            //cerr << "Using a 64 spp sampler" << endl;
-            jitter_sampler = jitterSamplers[2];
-            break;
-          case 256:
-            //cerr << "Using a 256 spp sampler" << endl;
-            jitter_sampler = jitterSamplers[3];
-            break;
-          default:
-            throw SCIRun::InternalError("Expected either 4, 16, 64, or 256 
spp", __FILE__, __LINE__);
-            break;
-          }
-          //cout << "Rendering a super sampled fragment" << endl;
-          jitter_sampler->renderFragment(context, frag);
+            //cout << "Rendering a super sampled fragment" << endl;
+            jitter_sampler->renderFragment(context, frag);
 
-          if (ShowTimeSupersample) {
-            ColorComponent color = CPUTime::currentSeconds()/60.;
-            for (int i = frag.begin(); i < frag.end(); i++) {
-              for ( int c = 0; c < Color::NumComponents; c++ )
-                frag.color[c][i] = color;
+            if (ShowTimeSupersample) {
+              ColorComponent color = CPUTime::currentSeconds()/60.;
+              for (int i = frag.begin(); i < frag.end(); i++) {
+                for ( int c = 0; c < Color::NumComponents; c++ )
+                  frag.color[c][i] = color;
+              }
             }
-          }
-
 
-          //Tile* childtile = new Tile;
-          ASSERT(context.proc < DeadlineImageTraverser::kMaxThreads);
-          Tile* childtile = tile_pools[context.proc].getItem();
-          childtile->xstart = x;
-          childtile->xend = xend;
-          childtile->ystart = y;
-          childtile->yend = yend;
-          childtile->xmag = newxmag;
-          childtile->ymag = newymag;
-          computePriority(childtile, frag);
-          childtiles.push_back(childtile);
-          image->set(frag);
+            //Tile* childtile = new Tile;
+            ASSERT(context.proc < DeadlineImageTraverser::kMaxThreads);
+            Tile* childtile = tile_pools[context.proc].getItem();
+            childtile->xstart = x;
+            childtile->xend = xend;
+            childtile->ystart = y;
+            childtile->yend = yend;
+            childtile->xmag = newxmag;
+            childtile->ymag = newymag;
+            computePriority(childtile, frag);
+            childtiles.push_back(childtile);
+            image->set(frag);
+          }
         }
       }
     } else {
@@ -530,7 +564,7 @@
       sum2 += luminance * luminance;
     }
     int n = frag.end()-frag.begin();
-    Color::ComponentType variance = (sum2 - sum * sum/n)/(n-1);
+    Color::ComponentType variance = (sum2 - sum * sum/n)/(n);
     tile->priority = variance * tile->xmag * tile->ymag;
   } else if(priority == Contrast){
     Color::ComponentType min, max;

Modified: trunk/Engine/ImageTraversers/DeadlineImageTraverser.h
==============================================================================
--- trunk/Engine/ImageTraversers/DeadlineImageTraverser.h       (original)
+++ trunk/Engine/ImageTraversers/DeadlineImageTraverser.h       Tue Aug 14 
15:53:22 2007
@@ -64,7 +64,7 @@
     virtual void renderImage(const RenderContext& context, Image* image);
 
     static ImageTraverser* create(const vector<string>& args);
-    static const int kNumJitterLevels = 4; // This provides 4, 16, 64, and 
256 spp
+    static const int kNumJitterLevels = 5; // This provides 4, 16, 64, and 
256 spp
   private:
     DeadlineImageTraverser(const DeadlineImageTraverser&);
     DeadlineImageTraverser& operator=(const DeadlineImageTraverser&);




  • [Manta] r1631 - trunk/Engine/ImageTraversers, boulos, 08/14/2007

Archive powered by MHonArc 2.6.16.

Top of page