Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2162 - in trunk: Model/Groups scenes


Chronological Thread 
  • From: "Solomon Boulos" <boulos@cs.utah.edu>
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2162 - in trunk: Model/Groups scenes
  • Date: Wed, 2 Apr 2008 14:40:57 -0600 (MDT)

Author: boulos
Date: Wed Apr  2 14:40:56 2008
New Revision: 2162

Modified:
   trunk/Model/Groups/DynBVH.cc
   trunk/scenes/triangleSceneViewer.cc
Log:
Model/Groups/DynBVH.cc

 Changing BVH num_samples to 16 to match Ingo's.

 Use centroid bounds instead of overall_bounds for placing the
 samples; results in massive improvement for conference scene... DynRT
 seems to drop geometry when I attempt to use triangle bounds instead
 of centroid bounds for the sample volume, so I can't really test this
 well... This has not yet been propogated to the parallel build stuff.

 Using Ingo's scaling trick to avoid need for dividing by area, etc.

scenes/triangleSceneViewer.cc

 Adding -overrideMatl to with the option of a variety of inputs for
 the material. I got tired of recompiling to switch between real
 diffuse (which at least computes shadow directions) and "eyelight".


Modified: trunk/Model/Groups/DynBVH.cc
==============================================================================
--- trunk/Model/Groups/DynBVH.cc        (original)
+++ trunk/Model/Groups/DynBVH.cc        Wed Apr  2 14:40:56 2008
@@ -27,7 +27,7 @@
 // NOTE(boulos): In Ingo's paper he says 16 works better than 8, but
 // I'm not sure for which models yet. For bunny it makes no
 // difference.
-const int BVH_num_samples = 8;
+const int BVH_num_samples = 16;
 
 #define LONGEST_AXIS 0
 #define USE_LAZY_BUILD 0
@@ -1834,21 +1834,14 @@
     return -1;
   }
 
-#if 1
-  // NOTE(boulos): Changing this to BBox& results in a completely
-  // different tree... When BVH_num_samples is higher on the bunny
-  // using BBox instead of BBox& produces slowdowns at each step. Using 
BBox& with lots of inlining produces
   BBox& overall_bounds = nodes[nodeID].bounds;
-#else
-  BBox overall_bounds;
+  BBox centroid_bounds;
   for (int i = objBegin; i < objEnd; i++) {
-    overall_bounds.extendByBox(obj_bounds[object_ids[i]]);
+    centroid_bounds.extendByPoint(obj_centroids[object_ids[i]]);
   }
-#endif
-  float inv_overall_area = 1.f/overall_bounds.computeArea();
 
   BVHCostEval best_cost;
-  best_cost.cost = BVH_C_isec * num_objects;
+  best_cost.cost = num_objects * overall_bounds.computeArea();
   best_cost.axis = -1;
   best_cost.position = FLT_MAX;
   best_cost.event = -1;
@@ -1863,14 +1856,14 @@
   const int num_samples = BVH_num_samples;
   SampleBin bins[3][num_samples];
 
-  Vector min_point = overall_bounds.getMin();
-  Vector max_point = overall_bounds.getMax();
+  Vector min_point = centroid_bounds.getMin();
+  Vector max_point = centroid_bounds.getMax();
   Vector width = max_point - min_point;
-  //Vector scale((num_samples/width[0]) * .999f,
-  //           (num_samples/width[1]) * .999f,
-  //           (num_samples/width[2]) * .999f);
+  Vector scale((num_samples/width[0]) * .999f,
+               (num_samples/width[1]) * .999f,
+               (num_samples/width[2]) * .999f);
 #ifdef LONGEST_AXIS
-  int longest_axis = overall_bounds.longestAxis();
+  int longest_axis = centroid_bounds.longestAxis();
 #endif
 
   for (int i = objBegin; i < objEnd; i++) {
@@ -1882,14 +1875,7 @@
     for (int axis = 0; axis < 3; axis++) {
 #endif
       // Sample bin is where this position would fall to the left
-      int which_bin = int(num_samples * (obj_centroid[axis] - 
min_point[axis])/width[axis]);
-      //int which_bin = int((obj_centroid[axis] - min_point[axis]) * 
scale[axis]);
-
-      if (width[axis] == 0)
-        which_bin = 0;
-      else if (which_bin >= num_samples)
-        which_bin = num_samples - 1;
-
+      int which_bin = int((obj_centroid[axis] - min_point[axis]) * 
scale[axis]);
       bins[axis][which_bin].count++;
       bins[axis][which_bin].bounds.extendByBox(obj_box);
     }
@@ -1934,10 +1920,6 @@
     for (int i = 0; i < num_samples - 1; i++) {
       float cost = (left_areas[i] * left_counts[i] +
                     right_areas[i] * right_counts[i]);
-      cost *= inv_overall_area;
-      cost *= BVH_C_isec;
-      cost += BVH_C_trav;
-
       if (cost < best_cost.cost) {
         // Found new best cost
         best_cost.cost = cost;
@@ -1956,7 +1938,6 @@
   output_axis = best_cost.axis;
   if ( output_axis != -1 ) {
     // write out object ids [objBegin,objEnd) in appropriate order
-
     int middle = partitionObjects(objBegin, objEnd, best_cost.axis, 
best_cost.position, left_bounds, right_bounds);
     if (middle == objBegin || middle == objEnd) {
       // Splitting didn't find a valid split, split in the middle unless

Modified: trunk/scenes/triangleSceneViewer.cc
==============================================================================
--- trunk/scenes/triangleSceneViewer.cc (original)
+++ trunk/scenes/triangleSceneViewer.cc Wed Apr  2 14:40:56 2008
@@ -14,6 +14,7 @@
 #include <Model/Groups/KDTree.h>
 #include <Model/Groups/ObjGroup.h>
 #include <Model/Groups/RecursiveGrid.h>
+#include <Model/Materials/Flat.h>
 #include <Model/Materials/Lambertian.h>
 #include <Model/Lights/PointLight.h>
 #include <Model/Lights/AreaLight.h>
@@ -25,6 +26,8 @@
 
 #include <string>
 #include <vector>
+#include <locale>
+#include <algorithm>
 #include <iostream>
 #include <fstream>
 
@@ -68,7 +71,7 @@
       printf("error loading or reading ply file: %s\n", modelName.c_str());
   }
   else if  (!strncmp(modelName.c_str()+modelName.length()-4, ".obj", 4)) {
-    frame = new ObjGroup(modelName.c_str(), NULL, triangleType);
+    frame = new ObjGroup(modelName.c_str(), matl, triangleType);
   }
 
   // NOTE(boulos): This code seems a bit strange, but what it's doing
@@ -83,7 +86,7 @@
   }
   if (interpolateNormals && !frame->hasVertexNormals())
     frame->interpolateNormals();
-  
+
   return frame;
 }
 
@@ -98,7 +101,7 @@
   bool useFaceNormals = false;
   bool smoothAnimation = false;
   float animationLength = 5; //in seconds
-
+  Material* overrideMatl = 0;
   bool setModel = false;
 
   MeshTriangle::TriangleType triangleType = 
MeshTriangle::KENSLER_SHIRLEY_TRI;
@@ -145,6 +148,23 @@
         triangleType = MeshTriangle::KENSLER_SHIRLEY_TRI;
       else
         throw IllegalArgument("scene triangleSceneViewer -triangleType", i, 
args);
+    } else if (arg == "-overrideMatl") {
+      string matlName;
+      if (!getStringArg(i, args, matlName))
+        throw IllegalArgument("scene triangleSceneViewer -overrideMatl", i, 
args);
+
+      std::transform(matlName.begin(), matlName.end(), matlName.begin(), 
::tolower);
+
+      if (matlName == "flat" ||
+          matlName == "eyelight") {
+        overrideMatl = new Flat(Color::white() * 0.8);
+      } else if (matlName == "lambert" ||
+                 matlName == "lambertian" ||
+                 matlName == "diffuse") {
+        overrideMatl = new Lambertian(Color::white() * 0.8);
+      } else {
+        throw IllegalArgument("scene triangleSceneViewer -overrideMatl 
unknown material", i, args);
+      }
     } else {
         argumentError(i, args);
     }
@@ -177,7 +197,7 @@
     for (size_t i=0; i < fileNames.size(); ++i) {
       modelName = fileNames[i];
       cout << "loading " << modelName <<endl;
-      Mesh* frame = LoadModel(modelName, NULL, triangleType, 
+      Mesh* frame = LoadModel(modelName, overrideMatl, triangleType,
                               useFaceNormals, interpolateNormals);
       animation->push_back(frame);
     }
@@ -187,7 +207,7 @@
   } else {
     // If we're just a single mesh, load it directly instead of using
     // the animation class.
-    Mesh* singleFrame = LoadModel(fileNames[0], NULL, triangleType,
+    Mesh* singleFrame = LoadModel(fileNames[0], overrideMatl, triangleType,
                                   useFaceNormals, interpolateNormals);
     as->setGroup(singleFrame);
     as->rebuild();
@@ -211,9 +231,9 @@
   Color area_light_color = Color(RGB(1,1,1))*20;
   Real areaLightDim = bbox.diagonal().length()*.30;
 
-  Parallelogram* area_light_geometry = 
+  Parallelogram* area_light_geometry =
     new Parallelogram(new Lambertian(area_light_color),
-                      lightOrigin, Vector(areaLightDim,0,0), 
+                      lightOrigin, Vector(areaLightDim,0,0),
                       Vector(0,0,areaLightDim));
 //   group->add(area_light_geometry);
 




  • [Manta] r2162 - in trunk: Model/Groups scenes, Solomon Boulos, 04/02/2008

Archive powered by MHonArc 2.6.16.

Top of page