Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r893 - in trunk/fox/disco_demo: Engine/Shaders StandAlone


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r893 - in trunk/fox/disco_demo: Engine/Shaders StandAlone
  • Date: Tue, 7 Feb 2006 11:42:32 -0700 (MST)

Author: abe
Date: Tue Feb  7 11:42:32 2006
New Revision: 893

Modified:
   trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
   trunk/fox/disco_demo/Engine/Shaders/AOShader.h
   trunk/fox/disco_demo/StandAlone/CMakeLists.txt
Log:


Removed Halton sequence code. Added #ifdef's for stratified vs. unstratified 
hemisphere sampling. Note this code wasn't used in the paper submission.
M    disco_demo/Engine/Shaders/AOShader.cc
M    disco_demo/Engine/Shaders/AOShader.h

Removed disco_demo from the cmake file.
M    disco_demo/StandAlone/CMakeLists.txt


Modified: trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
==============================================================================
--- trunk/fox/disco_demo/Engine/Shaders/AOShader.cc     (original)
+++ trunk/fox/disco_demo/Engine/Shaders/AOShader.cc     Tue Feb  7 11:42:32 
2006
@@ -36,7 +36,7 @@
 #include <Interface/Primitive.h>
 #include <Interface/Scene.h>
 #include <Core/Geometry/PointVector.h>
-#include <Core/Math/MT_RNG.h>
+#include <Core/Math/HaltonSequence.h>
 #include <SCIRun/Core/Math/Trig.h>
 
 #include <iostream>
@@ -49,59 +49,6 @@
 using namespace disco;
 using namespace disco::ambient_occlusion;
 
-static int primes[] = { 2, 3, 5, 7 };
-
-inline Real radical_inverse( int n, int b ) {
-
-  Real val = 0;
-  Real inv_b = 1.0 / (Real)b;
-  Real inv_bi = inv_b;
-
-  while (n > 0) {
-    int di = n % b;
-    val += di * inv_bi;
-    n /= b;
-    inv_bi *= inv_b;
-  }
-
-  return val;
-};
-
-inline Real folded_radical_inverse( int n, int b ) {
-
-  Real val = 0;
-  Real inv_b = 1.0 / (Real)b;
-  Real inv_bi = inv_b;
-  int offset = 0;
-
-  while ((val+b*inv_bi) != val) {
-    int d = ((n+offset) % b);
-    val += d * inv_bi;
-    n /= b;
-    inv_bi *= inv_b;
-    ++offset;
-  }
-
-  return val;
-};
-
-template< typename T, int S >
-class HaltonSequence {
-public:
-  HaltonSequence( int n_ = 1 ) : n( n ) { };
-
-  // Generate the next number in the sequence.
-  void next( PointT<T,S> &p ) {
-    for (int i=0;i<S;++i) {
-      p[i] = folded_radical_inverse( n, primes[i] );
-    }
-    ++n;
-  }
-  
-private:
-  int n;
-};
-
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 // Per sample shader.
@@ -139,8 +86,45 @@
     HaltonSequence<Real,2> sequence( context.proc*100 );
     PointT<Real,2> p;
 
+    // #define STRATIFY
+#ifdef STRATIFY
+    Real width = 1.0/(Real)kernel_width;
+    int task_size = total_directions/(kernel_width*kernel_width);
+
+    int i = 0;
+    for (int s=0;s<kernel_width;++s) {
+      for (int t=0;t<kernel_width;++t) {
+        
+        Real s_start = width*s;
+        Real t_start = width*t;
+        
+        for (int r=0;r<task_size;++r) {
+          
+          // Obtain the next point.
+          sequence.next( p );
+          
+          // Stratify the point.
+          p[0] = s_start+(p[0]*width);
+          p[1] = t_start+(p[1]*width);
+          
+          // Map to hemisphere.
+          Real phi = 2.0 * Pi * p[0];
+          Real r   = SCIRun::Sqrt( p[1] );
+          Real x   = r * Cos(phi);
+          Real y   = r * Sin(phi);
+          Real z   = 1.0 - x*x - y*y;
+          z = (z > 0.0) ? SCIRun::Sqrt(z) : 0.0;
+          
+          directions[i++] = Vector(x, y, z);
+          
+        }
+      }
+      
+    }
+    
+#else 
     for ( int i = 0; i < total_directions; i++ ) {
-
+      
       sequence.next( p );
       
       Real phi = 2.0 * Pi * p[0];
@@ -152,8 +136,10 @@
         
       directions[i] = Vector(x, y, z);
     }
+#endif
+
   }
-    
+  
 }
 
 /////////////////////////////////////////////////////////////////////////////

Modified: trunk/fox/disco_demo/Engine/Shaders/AOShader.h
==============================================================================
--- trunk/fox/disco_demo/Engine/Shaders/AOShader.h      (original)
+++ trunk/fox/disco_demo/Engine/Shaders/AOShader.h      Tue Feb  7 11:42:32 
2006
@@ -71,6 +71,10 @@
       
       virtual void shade( const RenderContext &context, RayPacket 
&ray_packet, TilePacket &tile_packet );
 
+      // Accessors.
+      int getTotalDirections() { return total_directions; };
+      int getKernelWidth() { return kernel_width; };
+
     private:
       // Members.
       int generated;

Modified: trunk/fox/disco_demo/StandAlone/CMakeLists.txt
==============================================================================
--- trunk/fox/disco_demo/StandAlone/CMakeLists.txt      (original)
+++ trunk/fox/disco_demo/StandAlone/CMakeLists.txt      Tue Feb  7 11:42:32 
2006
@@ -1,7 +1,6 @@
 
 ##########################################################
 # Add the disc_demo program  
-ADD_EXECUTABLE       (disco_demo disco_demo.cc)
 
 TARGET_LINK_LIBRARIES(disco_demo 
   FManta_static




  • [MANTA] r893 - in trunk/fox/disco_demo: Engine/Shaders StandAlone, abe, 02/07/2006

Archive powered by MHonArc 2.6.16.

Top of page