Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1198 - in trunk: DynLT scenes


Chronological Thread 
  • From: cgribble@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1198 - in trunk: DynLT scenes
  • Date: Mon, 2 Oct 2006 13:35:24 -0600 (MDT)

Author: cgribble
Date: Mon Oct  2 13:35:22 2006
New Revision: 1198

Modified:
   trunk/DynLT/DynLTGridSpheres.cc
   trunk/DynLT/DynLTGridSpheres.h
   trunk/DynLT/DynLTStatsCollector.cc
   trunk/DynLT/DynLTStatsCollector.h
   trunk/DynLT/DynLTWorker.cc
   trunk/scenes/dynlt.cc
   trunk/scenes/pnrrd.cc
Log:
Some last-minute hacks to the DynLT stuff for my dissertation

Modified: trunk/DynLT/DynLTGridSpheres.cc
==============================================================================
--- trunk/DynLT/DynLTGridSpheres.cc     (original)
+++ trunk/DynLT/DynLTGridSpheres.cc     Mon Oct  2 13:35:22 2006
@@ -105,6 +105,9 @@
 
         // Increment number of requests
         DynLTStatsCollector::TexturesRequestedPerFrame.increment();
+
+        // Increment number of visible particles
+        DynLTStatsCollector::NumberVisiblePerFrame.increment();
 #endif
 
         // Create and post message
@@ -114,15 +117,32 @@
           requested[particle]=priority;
       } else {
 #ifdef UPDATE_TIME
-        // Update priority only after UPDATE_TIME seconds
         if (Time::currentSeconds() - requested[particle] > UPDATE_TIME) {
+          // Update priority only after UPDATE_TIME seconds
           requested[particle]=computePriority(rays.getMinT(i));
           queue->updatePriority(particle, requested[particle]);
+
+#ifdef USE_STATS_COLLECTOR
+          // Update request time
+          latency[particle]=Time::currentSeconds();
+
+          // Updates count as a new request --> increment number of requests
+          DynLTStatsCollector::TexturesRequestedPerFrame.increment();
+#endif
         }
 #else
+        // Update priority
         requested[particle]=computePriority(rays.getMinT(i));
         queue->updatePriority(particle, requested[particle]);
+
+#ifdef USE_STATS_COLLECTOR
+        // Update request time
+        latency[particle]=Time::currentSeconds();
+
+        // Updates count as a new request --> increment number of requests
+        DynLTStatsCollector::TexturesRequestedPerFrame.increment();
 #endif
+#endif // UPDATE_TIME
       }
 
       // Use default ambient light while texture is invalid
@@ -158,9 +178,27 @@
       // Compute textured luminance
       sub.computeTextureCoordinates2(context);
 
+      // XXX - Using the ambient may just be a hack; DynLTWorker might need 
to
+      //       account for it, or maybe it's just wrong given that we're
+      //       computing global illumination (except that the background 
doesn't
+      //       contributed)...  I don't know, and at this point, I don't 
really
+      //       care!
+#define USE_AMBIENT 1
+#ifdef USE_AMBIENT
+      ColorArray ambient;
+      activeLights->getAmbientLight()->computeAmbient(context, rays, 
ambient);
+#endif
+
       for (unsigned int i=sub.begin(); i<sub.end(); ++i) {
-        Real luminance=computeLuminance(i, rays, particle);
+#ifdef USE_AMBIENT
+        Real luminance=computeLuminance(i, sub, particle);
+        luminance += 0.3*ambient[0][i] + 0.6*ambient[1][i] + 
0.1*ambient[2][i];
+
+        sub.setColor(i, diffuse.get(i)*luminance);
+#else
+        Real luminance=computeLuminance(i, sub, particle);
         sub.setColor(i, diffuse.get(i)*luminance);
+#endif
       }
     } else {
       // Request texture generation, if necessary
@@ -168,9 +206,6 @@
 #ifdef USE_STATS_COLLECTOR
         // Store request time
         latency[particle]=Time::currentSeconds();
-
-        // Increment number of requests
-        DynLTStatsCollector::TexturesRequestedPerFrame.increment();
 #endif
 
         // Create and post message
@@ -178,7 +213,17 @@
         DynLTMessage msg(particle, priority, this);
         if (queue->trySend(msg))
           requested[particle]=priority;
+
+#ifdef USE_STATS_COLLECTOR
+        // Increment number of requests
+        DynLTStatsCollector::TexturesRequestedPerFrame.increment();
+#endif
       } else {
+#ifdef USE_STATS_COLLECTOR
+        // Update request time
+        latency[particle]=Time::currentSeconds();
+#endif
+
 #ifdef UPDATE_TIME
         // Update priority only after UPDATE_TIME seconds
         if (Time::currentSeconds() - requested[particle] > UPDATE_TIME) {

Modified: trunk/DynLT/DynLTGridSpheres.h
==============================================================================
--- trunk/DynLT/DynLTGridSpheres.h      (original)
+++ trunk/DynLT/DynLTGridSpheres.h      Mon Oct  2 13:35:22 2006
@@ -8,6 +8,9 @@
 #include <SCIRun/Core/Thread/Mailbox.h>
 #include <SCIRun/Core/Thread/Time.h>
 
+// XXX:  temporary
+#include <iostream>
+
 #include <vector>
 using std::vector;
 
@@ -119,13 +122,13 @@
     
     double computePriority(Real t) const {
       // Time-stamp only
-      return Time::currentSeconds();
+      // return Time::currentSeconds();
 
       // Distance only (closest first)
       // return DBL_MAX - t;
 
-      // Time-stamp and distance
-      // return Time::currentSeconds() + (DBL_MAX - t);
+      // Weighted combination of time-stamp and distance
+      return 0.1*Time::currentSeconds() - 10.*t;
     }
 
     void resetRequested(int idx) {

Modified: trunk/DynLT/DynLTStatsCollector.cc
==============================================================================
--- trunk/DynLT/DynLTStatsCollector.cc  (original)
+++ trunk/DynLT/DynLTStatsCollector.cc  Mon Oct  2 13:35:22 2006
@@ -11,20 +11,26 @@
   cerr<<"Per-frame stats\n";
   cerr<<"  Requests:\t"<<TexturesRequestedPerFrame.getTotal()<<'\n';
   cerr<<"  Generated:\t"<<TexturesGeneratedPerFrame.getTotal()<<'\n';
+  cerr<<"  Visible:\t"<<NumberVisiblePerFrame.getTotal()<<'\n';
 #endif
 
   // Increment total counters
   TexturesRequested.increment(TexturesRequestedPerFrame.getTotal());
   TexturesGenerated.increment(TexturesGeneratedPerFrame.getTotal());
+  NumberVisible.increment(NumberVisiblePerFrame.getTotal());
 
   // Reset per-frame counters
   TexturesRequestedPerFrame.reset();
   TexturesGeneratedPerFrame.reset();
+  NumberVisiblePerFrame.reset();
 }
 
 void DynLTStatsCollector::dump(MantaInterface* /* unused */)
 {
   cerr<<'\n';
+  cerr<<"Number of visible particles\n";
+  cerr<<"  Total:\t"<<NumberVisible.getMaximum()<<'\n';
+  cerr<<'\n';
   cerr<<"Texture generation latency\n";
   cerr<<"  Average:\t"<<TexGenLatency.getAverage()<<" seconds\n";
   cerr<<"  Minimum:\t"<<TexGenLatency.getMinimum()<<" seconds\n";
@@ -59,3 +65,5 @@
 Stat DynLTStatsCollector::TexturesRequestedPerFrame;
 Stat DynLTStatsCollector::TexturesGenerated;
 Stat DynLTStatsCollector::TexturesGeneratedPerFrame;
+Stat DynLTStatsCollector::NumberVisible;
+Stat DynLTStatsCollector::NumberVisiblePerFrame;

Modified: trunk/DynLT/DynLTStatsCollector.h
==============================================================================
--- trunk/DynLT/DynLTStatsCollector.h   (original)
+++ trunk/DynLT/DynLTStatsCollector.h   Mon Oct  2 13:35:22 2006
@@ -21,10 +21,12 @@
     // Per-frame stats
     static Stat TexturesRequestedPerFrame;
     static Stat TexturesGeneratedPerFrame;
+    static Stat NumberVisiblePerFrame;
 
     // Per-session stats
     static Stat TexturesRequested;
     static Stat TexturesGenerated;
+    static Stat NumberVisible;
   };
 }
 

Modified: trunk/DynLT/DynLTWorker.cc
==============================================================================
--- trunk/DynLT/DynLTWorker.cc  (original)
+++ trunk/DynLT/DynLTWorker.cc  Mon Oct  2 13:35:22 2006
@@ -561,7 +561,7 @@
         }
 
         // Store the result
-        dynplt->texture[u][v] += context->Ka*ambient + context->Kd*diffuse;
+        dynplt->texture[u][v] += ambient + diffuse;
       }
 
       // Normalize the texel

Modified: trunk/scenes/dynlt.cc
==============================================================================
--- trunk/scenes/dynlt.cc       (original)
+++ trunk/scenes/dynlt.cc       Mon Oct  2 13:35:22 2006
@@ -60,6 +60,9 @@
   double runtime=1./25.;
   int minproc=0;
   int maxproc=INT_MAX;
+  double lx=10.;
+  double ly=10.;
+  double lz=10.;
 
   int argc=static_cast<int>(args.size());
   for(int i=0; i<argc; ++i) {
@@ -104,6 +107,13 @@
       } else if (arg=="-lifo") {
         fifo=false;
         lifo=true;
+      } else if (arg=="-light") {
+        if (!getDoubleArg(i, args, lx))
+          throw IllegalArgument("scene dynplt -light", i, args);
+        if (!getDoubleArg(i, args, ly))
+          throw IllegalArgument("scene dynplt -light", i, args);
+        if (!getDoubleArg(i, args, lz))
+          throw IllegalArgument("scene dynplt -light", i, args);
       } else if (arg=="-nbounces") {
         if (!getIntArg(i, args, max_depth))
           throw IllegalArgument("scene dynplt -nbounces", i, args);
@@ -157,6 +167,7 @@
         cerr<<"  -envmap [bg] <string>             environment map 
filename\n";
         cerr<<"  -i <string>                       particle data filename\n";
         cerr<<"  -lifo                             use lifo queue for 
texture requests\n";
+        cerr<<"  -light <x> <y> <z>                light position\n";
         cerr<<"  -nbounces <int>                   number of indirect 
nbounces\n";
         cerr<<"  -ncells <int>                     grid resolution\n";
         cerr<<"  -ngroups <int>                    number of sample 
groups\n";
@@ -254,15 +265,43 @@
     if (env_fname != "" && use_envmap)
       scene->setBackground(bg);
     else
-      scene->setBackground(new ConstantBackground(Color(RGB(0, 0, 0))));
+      // scene->setBackground(new ConstantBackground(Color(RGB(0, 0, 0))));
+      scene->setBackground(new ConstantBackground(Color(RGB(1, 1, 1))));
     scene->setObject(tsteps);
 
     // Add lights
     LightSet* lights=new LightSet();
-    lights->add(new PointLight(Vector(10, 10, 10), Color(RGB(1, 1, 1))));
+    lights->add(new PointLight(Vector(lx, ly, lz), Color(RGB(1, 1, 1))));
+
     lights->setAmbientLight(new ConstantAmbient(Color(RGB(0.4, 0.4, 0.4))));
     scene->setLights(lights);
 
+    // Dissertation --> Figure 6.14
+    // bin/manta -np 8 -res 768x768 -scene "lib/libscene_dynlt.so(-i 
/home/sci/cgribble/csafe/particle/data/cylinder/spheredata022-crop.nrrd 
-radius 0.0005 -depth 2 -ncells 4 -cidx 6 -light 0.00382502 0.00941466 
0.0387222 -timed 0.5)" -imagedisplay "file(-prefix dlt -fps)" -imagetype rgb8
+    // bin/manta -np 8 -res 768x768 -scene "lib/libscene_dynlt.so(-i 
/home/sci/cgribble/csafe/particle/data/cylinder/spheredata022-crop.nrrd 
-radius 0.0005 -depth 2 -ncells 4 -cidx 7 -light 0.00382502 0.00941466 
0.0387222 -timed 0.5)"
+    // -light 0.00382502 0.00941466 0.0387222
+    /*
+    scene->addBookmark("cylinder zoom",
+                       Vector(0.0258901, 0.0350857, 0.0101507),
+                       Vector(0.0265856, -0.0189865, -0.00485091),
+                       Vector(-0.987557, 0.157203, 0.00437984),
+                       33.0838);
+    scene->addBookmark("cylinder",
+                       Vector(0.0341205, 0.0316136, -0.0175898),
+                       Vector(0.0433734, -0.0201009, 0.00214181),
+                       Vector(-1, 0, 0),
+                       60.0);
+    scene->addBookmark("thunder zoom",
+                       Vector(-0.0243489, -0.0387558, -0.0511661),
+                       Vector(0.0457378, -0.0446916, 0.0355259),
+                       Vector(0, 1, 0),
+                       45.0);
+    scene->addBookmark("bullet",
+                       Vector(-0.00660217, 0.0288114, 0.0100214),
+                       Vector(0.00911079, -0.0242788, 0.000859511),
+                       Vector(-0.161427, -0.0436313, 0.98592),
+                       7.03459);
+    */
     /*
       scene->addBookmark("debug 0", Vector(0.06, 26.9721, 0.06),
       Vector(0.06, 0.06, 0.06), Vector(0, 0, 1), 0.59);

Modified: trunk/scenes/pnrrd.cc
==============================================================================
--- trunk/scenes/pnrrd.cc       (original)
+++ trunk/scenes/pnrrd.cc       Mon Oct  2 13:35:22 2006
@@ -35,6 +35,10 @@
   double radius=1.;
   int ridx=-1;
   Group* world=0;
+  double lx=10.;
+  double ly=10.;
+  double lz=10.;
+
   for(int i=0; i<argc; ++i) {
     string arg=args[i];
 #if 0
@@ -57,6 +61,13 @@
     } else if (arg=="-i") {
       if (!getStringArg(i, args, fname))
         throw IllegalArgument("scene pnrrd -i", i, args);
+    } else if (arg=="-light") {
+      if (!getDoubleArg(i, args, lx))
+        throw IllegalArgument("scene dynplt -light", i, args);
+      if (!getDoubleArg(i, args, ly))
+        throw IllegalArgument("scene dynplt -light", i, args);
+      if (!getDoubleArg(i, args, lz))
+        throw IllegalArgument("scene dynplt -light", i, args);
     } else if (arg=="-ncells") {
       if (!getIntArg(i, args, ncells))
         throw IllegalArgument("scene pnrrd -ncells", i, args);
@@ -101,7 +112,8 @@
   scene->setObject(tsteps);
 
   LightSet* lights=new LightSet();
-  lights->add(new PointLight(Vector(1, 0, -1), Color(RGB(1, 1, 1))));
+  lights->add(new PointLight(Vector(lx, ly, lz), Color(RGB(1, 1, 1))));
+  // lights->add(new PointLight(Vector(1, 0, -1), Color(RGB(1, 1, 1))));
   //  lights->add(new PointLight(Vector(0, 0, 0), Color(RGB(1, 1, 1))));
   lights->setAmbientLight(new ConstantAmbient(Color(RGB(0.4, 0.4, 0.4))));
   scene->setLights(lights);




  • [MANTA] r1198 - in trunk: DynLT scenes, cgribble, 10/02/2006

Archive powered by MHonArc 2.6.16.

Top of page