Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1084 - in trunk: Engine/Control Interface Model/Materials Model/Readers scenes


Chronological Thread 
  • From: cgribble@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1084 - in trunk: Engine/Control Interface Model/Materials Model/Readers scenes
  • Date: Wed, 24 May 2006 12:25:41 -0600 (MDT)

Author: cgribble
Date: Wed May 24 12:25:39 2006
New Revision: 1084

Modified:
   trunk/Engine/Control/DynPLTWorker.cc
   trunk/Interface/RayPacket.h
   trunk/Model/Materials/DynPLTMaterial.cc
   trunk/Model/Readers/ParticleNRRD.cc
   trunk/Model/Readers/ParticleNRRD.h
   trunk/scenes/dynplt.cc
   trunk/scenes/pnrrd.cc
Log:
scenes/dynplt.cc
  Removed debugging bookmarks
  Changed light position, particle color, and background color
  Changed depth cmdln parameter to nbounces

scenes/pnrrd.cc
  Added bookmarks (same as dynplt scene)

Model/Materials/DynPLTMaterial.cc
  Removed unnecessary #include <iostream>
  Removed XXX message

Model/Readers/ParticleNRRD.h
Model/Readers/ParticleNRRD.cc
  ParticleNRRD::readFile(...) now returns a bool (success/failure)

Interface/RayPacket.h
  Fixed indexing error in setHitPosition(...) that was the source of all the
    direct lighting computation errors

Engine/Control/DynPLTWorker.cc
  Tracked down bug in direct lighting (see above)
  Turned indirect lighting computation on; seems to work with the eight 
spheres
    example
  Segfaults when nbounces >= 3 on my Mac, but not sure why; works fine on 
arachne


Modified: trunk/Engine/Control/DynPLTWorker.cc
==============================================================================
--- trunk/Engine/Control/DynPLTWorker.cc        (original)
+++ trunk/Engine/Control/DynPLTWorker.cc        Wed May 24 12:25:39 2006
@@ -14,6 +14,9 @@
 using namespace Manta;
 using namespace std;
 
+// XXX:  the exit strategy only works occasionally (no segfault) when the 
queue
+//       isn't empty, and never when it is empty
+
 DynPLTContext::DynPLTContext(SCIRun::Mailbox<const Sphere*>* queue,
                              Scene* scene, unsigned int ngroups,
                              unsigned int nsamples, unsigned int max_depth) :
@@ -76,9 +79,6 @@
   delete [] hidx;
 }
 
-#include <iostream>
-using std::cerr;
-
 void DynPLTWorker::run(void)
 {
   // Grab useful information from the DynPLT context
@@ -109,8 +109,10 @@
 
     unsigned int xres=dynplt->getXRes();
     unsigned int yres=dynplt->getYRes();
-    Real inv_width=1/static_cast<Real>(xres - 1);
-    Real inv_height=1/static_cast<Real>(yres - 1);
+    // Real inv_width=1/static_cast<Real>(xres - 1);
+    // Real inv_height=1/static_cast<Real>(yres - 1);
+    Real inv_width=1/static_cast<Real>(xres);
+    Real inv_height=1/static_cast<Real>(yres);
 
     // Intialize the textures
     bzero(dynplt->texture, xres*yres*sizeof(float));
@@ -198,7 +200,6 @@
               // Normalize directions for proper dot product computation
               shadowRays.normalizeDirections();
 
-              // XXX:  we're not actually getting shadows...
               for (int i=shadowRays.begin(); i<shadowRays.end(); ++i) {
                 if (!shadowRays.wasHit(i)) {
                   // Not in shadow, so compute the direct contribution
@@ -217,8 +218,6 @@
             if (d >= max_depth - 1)
               break;
 
-#if 0
-            // XXX:  not sure if this is correct...
             for (int i=rays.begin(); i<rays.end(); ++i) {
               // Compute an ONB at the surface point
               Vector normal=rays.getNormal(i);
@@ -247,7 +246,6 @@
               rays.setDirection(i, dir);
               
               // Update attenutation
-              // XXX:  is this correct?
               atten.set(i, atten.get(i)*Dot(normal, dir));
             }
 
@@ -279,7 +277,7 @@
                   if (dotprod>0) {
                     rays.setHitPosition(validRays, sub.getHitPosition(j));
                     rays.setNormal(validRays, sub.getNormal(j));
-                    atten.set(validRays, atten.get(i));
+                    atten.set(validRays, atten.get(j));
                     ++validRays;
                   } else {
                     // An invalid hit, resulting from:
@@ -304,14 +302,12 @@
                 while (end < rays.end() && !rays.wasHit(end))
                   ++end;
 
-#if 0
                 // Shade the rays, and accumulate background color
                 RayPacket sub(rays, i, end);
                 scene->getBackground()->shade(rctx, sub);
 
-                for (unsigned int j=i; j<end; ++j)
-                  result += rays.getColor(j).luminance();
-#endif
+                for (unsigned int j=sub.begin(); j<sub.end(); ++j)
+                  result += sub.getColor(j).luminance();
 
                 i=end;
               }
@@ -324,7 +320,6 @@
             // Update the ray packet configuration, loop to next depth
             rays.setDepth(rays.getDepth() + 1);
             rays.resize(validRays);
-#endif
           }
 
           // Store the result

Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Wed May 24 12:25:39 2006
@@ -526,7 +526,7 @@
     Vector setHitPosition(int which, const Vector& hit) const
     {
       for(int i=0;i<3;i++)
-        data->hitPosition[i][which] = hit[which];
+        data->hitPosition[i][which] = hit[i];
     }
     void computeHitPositions()
     {

Modified: trunk/Model/Materials/DynPLTMaterial.cc
==============================================================================
--- trunk/Model/Materials/DynPLTMaterial.cc     (original)
+++ trunk/Model/Materials/DynPLTMaterial.cc     Wed May 24 12:25:39 2006
@@ -32,9 +32,6 @@
   // Do nothing
 }
 
-#include <iostream>
-using std::cerr;
-
 void DynPLTMaterial::shade(const RenderContext& context, RayPacket& rays) 
const
 {
   if (valid) {
@@ -46,8 +43,6 @@
     rays.computeTextureCoordinates2(context);
 
     for (unsigned int i=rays.begin(); i < rays.end(); ++i) {
-      // XXX:  there's still something subtle going on here..  not sure if 
it's
-      //       in x or y (but probably y); see bookmarked views in dynplt 
scene
       // Wrap in x (assumes x is a power of two)
       Real x=rays.getTexCoords2(i, 0)*XRES;
       int lx=static_cast<int>(x) & (XRES - 1);

Modified: trunk/Model/Readers/ParticleNRRD.cc
==============================================================================
--- trunk/Model/Readers/ParticleNRRD.cc (original)
+++ trunk/Model/Readers/ParticleNRRD.cc Wed May 24 12:25:39 2006
@@ -17,7 +17,10 @@
 
 ParticleNRRD::ParticleNRRD(string const fname)
 {
-  readFile(fname);
+  if (!readFile(fname)) {
+    cerr<<"ParticleNRRD::ParticleNRRD:  fatal error\n";
+    exit(-1);
+  }
 }
 
 ParticleNRRD::~ParticleNRRD(void)
@@ -26,7 +29,7 @@
     delete pdata;
 }
 
-void ParticleNRRD::readFile(string const fname)
+bool ParticleNRRD::readFile(string const fname)
 {
   // Load particle data
   Nrrd* pnrrd=nrrdNew();
@@ -35,7 +38,7 @@
     cerr<<"Error loading particle data:  "<<err<<'\n';
     free(err);
     biffDone(NRRD);
-    return;
+    return false;
   }
   
   // Initialize variables
@@ -47,4 +50,6 @@
       <<" data values/particles) from \""<<fname<<"\"\n";
 
   pnrrd=nrrdNix(pnrrd);
+
+  return true;
 }

Modified: trunk/Model/Readers/ParticleNRRD.h
==============================================================================
--- trunk/Model/Readers/ParticleNRRD.h  (original)
+++ trunk/Model/Readers/ParticleNRRD.h  Wed May 24 12:25:39 2006
@@ -17,7 +17,7 @@
     float* getParticleData(void) const { return pdata; }
     float* getParticleData(void) { return pdata; }
 
-    void readFile(string const fname);
+    bool readFile(string const fname);
 
   private:
     unsigned int nvars;

Modified: trunk/scenes/dynplt.cc
==============================================================================
--- trunk/scenes/dynplt.cc      (original)
+++ trunk/scenes/dynplt.cc      Wed May 24 12:25:39 2006
@@ -20,7 +20,7 @@
 #include <iostream>
 #include <sgi_stl_warnings_on.h>
 
-#define RENDER_THREAD_STACKSIZE 8*1024*1024
+#define WORKER_THREAD_STACKSIZE 8*1024*1024
 
 using namespace Manta;
 using namespace SCIRun;
@@ -49,9 +49,10 @@
       if (!getStringArg(i, args, s))
         throw IllegalArgument("scene dynplt -bv", i, args);
       world=context.manta_interface->makeGroup(s);
-    } else if (arg=="-depth") {
+    } else if (arg=="-nbounces") {
       if (!getIntArg(i, args, max_depth))
-        throw IllegalArgument("scene dynplt -depth", i, args);
+        throw IllegalArgument("scene dynplt -nbounces", i, args);
+      ++max_depth;
     } else if (arg=="-i") {
       if (!getStringArg(i, args, fname))
         throw IllegalArgument("scene dynplt -i", i, args);
@@ -76,7 +77,7 @@
     } else {
       cerr<<"Valid options for scene dynplt:\n";
       cerr<<"  -bv <string>      bounding volume {bvh|grid|group}\n";
-      cerr<<"  -depth <int>      path trace depth\n";
+      cerr<<"  -nbounces <int>   number of indirect nbounces\n";
       cerr<<"  -i <string>       particle data filename\n";
       cerr<<"  -ngroups <int>    number of sample groups\n";
       cerr<<"  -nsamples <int>   number of samples/texel\n";
@@ -109,7 +110,7 @@
     DynPLTWorker* worker=new DynPLTWorker(dpltctx, i);
     Thread* thread=new Thread(worker, name.str().c_str(), 0,
                               Thread::NotActivated);
-    thread->setStackSize(RENDER_THREAD_STACKSIZE);
+    thread->setStackSize(WORKER_THREAD_STACKSIZE);
     thread->activate(false);
     
     // Register termination callback
@@ -130,27 +131,20 @@
       radius=pdata[idx + ridx];
     
     // Material* dynplt=new DynPLTMaterial(queue, Color(RGB(1, 1, 1)));
-    Material* dynplt=new DynPLTMaterial(queue, Color(RGB(1, 0, 0)));
+    Material* dynplt=new DynPLTMaterial(queue, Color(RGB(0, 1, 0)));
     world->add(new Sphere(dynplt, Vector(x, y, z), radius));
   }
 
   // Initialize the scene
-  // scene->setBackground(new ConstantBackground(Color(RGB(0, 0, 0))));
-  scene->setBackground(new ConstantBackground(Color(RGB(1, 1, 1))));
+  scene->setBackground(new ConstantBackground(Color(RGB(0, 0, 0))));
   scene->setObject(world);
 
   // Add lights
   LightSet* lights=new LightSet();
-  lights->add(new PointLight(Vector(1, 1, 1), Color(RGB(1, 1, 1))));
+  lights->add(new PointLight(Vector(10, 10, 10), Color(RGB(1, 1, 1))));
   lights->setAmbientLight(new ConstantAmbient(Color(RGB(0.4, 0.4, 0.4))));
   scene->setLights(lights);
 
-  scene->addBookmark("shadow debug 0", Vector(4.55511, 5.33192, 1.09352),
-                     Vector(0.00492657, 0.0220694, 0.198221),
-                     Vector(0.378617, -0.459881, 0.803217), 0.00103794);
-  scene->addBookmark("shadow debug 1", Vector(4.55511, 5.33192, 1.09352),
-                     Vector(0.00492657, 0.0220694, 0.198221),
-                     Vector(0.378617, -0.459881, 0.803217), 0.00909911);
   scene->addBookmark("view 0", Vector(0.02, 1.02, 0.20),
                      Vector(0.02, 0.02, 0.20), Vector(0, 0, 1),
                      0.59);
@@ -160,14 +154,6 @@
   scene->addBookmark("view 2", Vector(-0.83, 0.85, 4.71),
                      Vector(0.02, 0.01, 0.29), Vector(-0.59, -0.59, 0.59),
                      0.59);
-  scene->addBookmark("broken interpolation 1",
-                     Vector(0.25853, 0.146471, 1.16313),
-                     Vector(0.0207405, 0.0211326, 0.199939),
-                     Vector(-0.539328, -0.80769, 0.238249), 0.0132616);
-  scene->addBookmark("broken interpolation 2",
-                     Vector(0.00145609, 0.584749, 1.02512),
-                     Vector(0.0208755, 0.020066, 0.200044),
-                     Vector(-0.362337, -0.773111, 0.520588), 0.0709904);
 
   return scene;
 }

Modified: trunk/scenes/pnrrd.cc
==============================================================================
--- trunk/scenes/pnrrd.cc       (original)
+++ trunk/scenes/pnrrd.cc       Wed May 24 12:25:39 2006
@@ -83,9 +83,15 @@
   lights->setAmbientLight(new ConstantAmbient(Color(RGB(0.4, 0.4, 0.4))));
   scene->setLights(lights);
 
-  scene->addBookmark("shadow debug", Vector(4.55511, 5.33192, 1.09352),
-                     Vector(0.00492657, 0.0220694, 0.198221),
-                     Vector(0.378617, -0.459881, 0.803217), 0.00103794);
+  scene->addBookmark("view 0", Vector(0.02, 1.02, 0.20),
+                     Vector(0.02, 0.02, 0.20), Vector(0, 0, 1),
+                     0.59);
+  scene->addBookmark("view 1", Vector(0.83, 0.85, 4.71),
+                     Vector(0.02, 0.01, 0.29), Vector(-0.54, -0.58, 0.59),
+                     0.59);
+  scene->addBookmark("view 2", Vector(-0.83, 0.85, 4.71),
+                     Vector(0.02, 0.01, 0.29), Vector(-0.59, -0.59, 0.59),
+                     0.59);
 
   return scene;
 }




  • [MANTA] r1084 - in trunk: Engine/Control Interface Model/Materials Model/Readers scenes, cgribble, 05/24/2006

Archive powered by MHonArc 2.6.16.

Top of page