Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r581 - in branches/itanium2: Engine/Control Interface Model/Groups Model/Materials StandAlone scenes


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r581 - in branches/itanium2: Engine/Control Interface Model/Groups Model/Materials StandAlone scenes
  • Date: Thu, 29 Sep 2005 12:59:25 -0600 (MDT)

Author: abe
Date: Thu Sep 29 12:59:23 2005
New Revision: 581

Modified:
   branches/itanium2/Engine/Control/RTRT.cc
   branches/itanium2/Interface/HitInfo.h
   branches/itanium2/Model/Groups/FrustumKDTree.cc
   branches/itanium2/Model/Groups/FrustumKDTree.h
   branches/itanium2/Model/Groups/KDTree.cc
   branches/itanium2/Model/Groups/KDTree.h
   branches/itanium2/Model/Groups/TransparentKDTree.cc
   branches/itanium2/Model/Materials/LambertianAlt.cc
   branches/itanium2/StandAlone/frust-test.cc
   branches/itanium2/scenes/boeing777.cc
Log:



Slight modification to traversal to eliminate some double/float conversion 
from the loop. Aligned traversal stack to 
cache line-- possible improvement. 

Added several options to 777 scene loader to benchmark different materials. 

-alpha <alpha>
-lambertianalt (alpha=1.0 without transparent traversal)
-phong <exp> <reflection> **default**
-ambient <max dist> <secondary rays>



M    scenes/boeing777.cc
M    StandAlone/frust-test.cc
M    Model/Groups/TransparentKDTree.cc
M    Model/Groups/FrustumKDTree.cc
M    Model/Groups/FrustumKDTree.h
M    Model/Groups/KDTree.cc
M    Model/Groups/KDTree.h
M    Model/Materials/LambertianAlt.cc
M    Interface/HitInfo.h
M    Engine/Control/RTRT.cc


Modified: branches/itanium2/Engine/Control/RTRT.cc
==============================================================================
--- branches/itanium2/Engine/Control/RTRT.cc    (original)
+++ branches/itanium2/Engine/Control/RTRT.cc    Thu Sep 29 12:59:23 2005
@@ -1164,6 +1164,8 @@
   transaction_lock.unlock();
 }
 
+#include <Interface/RayPacket.h>
+
 
///////////////////////////////////////////////////////////////////////////////
 
 // Experimental. Shoot one ray from the calling thread. Populates the result 
ray

Modified: branches/itanium2/Interface/HitInfo.h
==============================================================================
--- branches/itanium2/Interface/HitInfo.h       (original)
+++ branches/itanium2/Interface/HitInfo.h       Thu Sep 29 12:59:23 2005
@@ -101,6 +101,13 @@
                                return false;
       }
     }
+    void set_hit(double t, const Material* matl, const Primitive* prim,
+                 const TexCoordMapper* tex) {
+      min_t=t;
+      hitMatl = matl;
+      hitPrim = prim;
+      hitTex = tex;
+    }
     static const size_t MaxScratchpadSize = 128;
                
                void copyScratchpad( const HitInfo &info ) {

Modified: branches/itanium2/Model/Groups/FrustumKDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/FrustumKDTree.cc     (original)
+++ branches/itanium2/Model/Groups/FrustumKDTree.cc     Thu Sep 29 12:59:23 
2005
@@ -114,19 +114,136 @@
   //  PacketFrustum frustum( rays );
 
   ///////////////////////////////////////////////////////////////////////
-  // Intersect the frustum down the kdtree.
-
-
+  // Perform the EP search.
+  
+  
 
 }
 
+/////////////////////////////////////////////////////////////////////////
+// Perform the EP search.
+struct BifurcationEntry {
+  BBox         bounds;
+  KDTreeNode  *parent;
+  short int    next_child;
+};
+
+KDTreeNode *
+FrustumKDTree::ep_search( KDTreeNode *start_node,
+                          PacketFrustum &frustum,
+                          const BBox &initial_bounds ) 
+{
+
+  // Bifurcation stack.
+  BifurcationEntry bifurcation_stack[128]; 
+  int bi_stack = 1;  // Points to the top entry.
+  
+  
/////////////////////////////////////////////////////////////////////////////
+  // Initialize the stack, determine the closer of the start node's children.
+  
+  // Determine which side of the start node's split the frustum origin is on.
+  unsigned int closer = (frustum.origin()[start_node->axis()] > 
start_node->split());
+  
+  // First two entries are the first two children.
+  bifurcation_stack[0].bounds     = initial_bounds;
+  bifurcation_stack[0].parent     = start_node;
+  bifurcation_stack[0].next_child = closer;
+  
+  bifurcation_stack[1].bounds     = initial_bounds;
+  bifurcation_stack[1].parent     = start_node;
+  bifurcation_stack[1].next_child = (1 - closer);
+  
+  // Candidate entry point.
+  KDTreeNode *candidate = 0;
+  
+  // Traversal bounds.
+  BBox node_bounds = initial_bounds;
+  
+  
/////////////////////////////////////////////////////////////////////////////
+  // Main EP search loop.
+  while (bi_stack >= 0) {
+    
+    // Restore the bounds of this node.
+    BBox node_bounds = bifurcation_stack[bi_stack].bounds;
+    
+    // Determine the next child
+    KDTreeNode *node = bifurcation_stack[bi_stack].parent;
+    
+    node = node->getChild( bifurcation_stack[bi_stack].next_child );
+    
+    
///////////////////////////////////////////////////////////////////////////
+    // Find a leaf.
+    while (node->isInternal()) {
+    
+      // Check to see if the current node is a bifurcation point.
+      IntersectCase c = frustum_node_intersect( node, frustum, node_bounds );
+      unsigned int closer;
+    
+      if ((c & INTERSECT_BOTH) == INTERSECT_BOTH) {
+      
+        // Determine which child to use.
+        closer = (c >> 2);
+      
+        
///////////////////////////////////////////////////////////////////////
+        // Push a parent on the bifurcation stack.
+        bi_stack++;
+        
+        // Save all of the bounds !!!
+        bifurcation_stack[bi_stack].bounds = node_bounds;
+      
+        // Add the node to the bifurcation stack.
+        bifurcation_stack[bi_stack].parent = node;
+        
+        // Determine the further of the child nodes.
+        bifurcation_stack[bi_stack].next_child = ((~closer) & 0x1); // ??? 
Check ???
+        
+      }
+      else {
+      
+        // Determine which child to proceed with.
+        closer = c;
+      }
+      
+      
/////////////////////////////////////////////////////////////////////////
+      // Continue the traversal to the leaves.
+      
+      // Update the node bounds.
+      node_bounds[closer][node->axis()] = node->split();
+      
+      // Move to the next node.
+      node = node->getChild( closer );
+    }
+    
+    // Check to see if the frustum intersects this leaf.
+    if (frustum_leaf_intersect( frustum, node_bounds )) {
+    
+      // Update the candidate node.
+      if (candidate == 0) {
+        candidate = node;
+      }
+      else {
+        candidate = bifurcation_stack[bi_stack].parent;
+      }
+      
+      // Check to see if all of the rays hit this leaf????
+      // Termination condition 3B.
+      
+      // ...
+    }
+  
+    // Pop the bifurcation stack.
+    bi_stack--;
+  
+  }
+  
+  return candidate;
+}                          
 
 /////////////////////////////////////////////////////////////////////////
 // Intersect the specified frustum with an internal node.
 FrustumKDTree::IntersectCase
-FrustumKDTree::frustum_node_intersect(const RenderContext& context,
-                                      const KDTreeNode *node,
-                                      const PacketFrustum &frustum,
+FrustumKDTree::frustum_node_intersect(KDTreeNode *node,
+                                      PacketFrustum &frustum,
                                       const BBox &node_bounds )
 {
   typedef PointT<float,2> Point2f;
@@ -266,6 +383,9 @@
   }
 #endif
 
+  
/////////////////////////////////////////////////////////////////////////////
+  // Determine which child or both needs to be intersected (hopefully wo/ 
branches)

   // Which side of the split plane is the ray packet on.
   unsigned int origin = (frustum.origin()[axis] > node->split());
   unsigned int result = INTERSECT_NONE;
@@ -290,8 +410,7 @@
 // glorified bounding box test that takes into consideration 4 rays
 // (the edges of the frustum) instead of 1.  It does produce some
 // false positives, but it should never generate false negatives.
-bool FrustumKDTree::frustum_leaf_intersect(const RenderContext& context,
-                                           PacketFrustum &frustum,
+bool FrustumKDTree::frustum_leaf_intersect(PacketFrustum &frustum,
                                            const BBox& leaf_bounds ) {
   Vector entry[4];
   Vector exit[4];

Modified: branches/itanium2/Model/Groups/FrustumKDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/FrustumKDTree.h      (original)
+++ branches/itanium2/Model/Groups/FrustumKDTree.h      Thu Sep 29 12:59:23 
2005
@@ -86,7 +86,13 @@
       void packet_intersect(const RenderContext& context, RayPacket &rays );
 
       
/////////////////////////////////////////////////////////////////////////
-      // Intersect the specified frustum with the kdtree.
+      // Perform the EP search.
+      KDTreeNode *ep_search( KDTreeNode *start_node,
+                             PacketFrustum &frustum,
+                             const BBox &node_bounds );
+
+      
/////////////////////////////////////////////////////////////////////////
+      // Intersect the specified frustum with the kdtree
       enum IntersectCase { INTERSECT_NONE = 0x0,  // Cannot be determined by
                                                   // basic tests.
                            INTERSECT_MIN  = 0x1,
@@ -94,14 +100,12 @@
                            INTERSECT_BOTH = 0x3 };
 
       // Intersect the specified frustum with an internal node.
-      IntersectCase frustum_node_intersect(const RenderContext& context,
-                                           const KDTreeNode *node,
-                                           const PacketFrustum &frustum,
+      IntersectCase frustum_node_intersect(KDTreeNode *node,
+                                           PacketFrustum &frustum,
                                            const BBox &node_bounds );
 
       // Intersect the specified frustum with a leaf.
-      bool frustum_leaf_intersect(const RenderContext& context,
-                                  PacketFrustum &frustum,
+      bool frustum_leaf_intersect(PacketFrustum &frustum,
                                   const BBox& leaf_bounds );
 
     public:

Modified: branches/itanium2/Model/Groups/KDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.cc    (original)
+++ branches/itanium2/Model/Groups/KDTree.cc    Thu Sep 29 12:59:23 2005
@@ -49,6 +49,9 @@
 using std::cerr;
 using std::endl;
 
+#define SHOW_DUPLICATES 0
+
+unsigned long global_counter = 0;
 
 
///////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////
@@ -80,7 +83,11 @@
 // INTERSECT TRIANGLES  INTERSECT TRIANGLES  INTERSECT TRIANGLES  INTERSECT 
TRI
 
///////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////
-int KDTree::intersectTriangles(const Ray* ray, unsigned int listBegin, int 
listSize, float maxDist, void *userData, const RenderContext &context) const
+int KDTree::intersectTriangles(const Ray* ray,
+                               unsigned int listBegin, int listSize,
+                               float maxDist, void *userData,
+                               const RenderContext &context,
+                               RayTriangleMailbox &mailbox ) const
 {
        int i;
        RayTriIntersectUserData *ud = (RayTriIntersectUserData*)userData;
@@ -92,30 +99,46 @@
        
        // Intersect the ray with all the triangles. 
        int listEnd = listBegin+listSize;
-       
+
+  // if (listSize < 40)
+  //  ud->duplicate = 4;
+  
        #pragma swp
        for (i = listBegin; i < listEnd; i++) {
                int triIdx = triIndices->get(i);
                Triangle &tri = tris->get(triIdx);
                float t, u, v;
-               
-               // if (intersectTriangle3Edge( direction, origin, tri.edge1, 
tri.edge2, tri[0], t, u, v )) {
-               if(intersect_triangle3_edge( &origin, &direction, &tri[0], 
&t, &u, &v, &tri.edge1, &tri.edge2 )) {
-               
-                       // Check to see if the t value is closer.
-                       if (t < maxDist) {
-                               maxDist = t;
-                               nearest_u = u;
-                               nearest_v = v;
-                               nearest_tri = triIdx;
-                       }
-               }
+
+#if SHOW_DUPLICATES
+    //if (!mailbox.only_check( ray, triIdx )) {
+      // global_counter++;
+    //ud->duplicate++;
+    //}
+#endif
+
+    // Insert mailbox check here.
+    // if (intersectTriangle3Edge( direction, origin, tri.edge1, tri.edge2, 
tri[0], t, u, v )) {
+    if (mailbox.not_mapped( ray, triIdx )) {
+      
+      
+      if(/*mailbox.not_mapped( ray, triIdx ) &&*/ intersect_triangle3_edge( 
&origin, &direction, &tri[0], &t, &u, &v, &tri.edge1, &tri.edge2 )) {
+      
+      // Check to see if the t value is closer.
+      if (t < maxDist) {
+        maxDist = t;
+        // nearest_u = u;
+        // nearest_v = v;
+        nearest_tri = triIdx;    
+      }
+      }
+    }
+
        }
        
        if (nearest_tri >= 0) {
-               ud->rayHit.t = maxDist;
-               ud->rayHit.u = nearest_u;
-               ud->rayHit.v = nearest_v;
+               ud->rayHit.t = maxDist; 
+               // ud->rayHit.u = nearest_u;
+               // ud->rayHit.v = nearest_v;
                ud->rayHitTriIndex = nearest_tri;
                return 1;
                
@@ -134,7 +157,7 @@
        
        // Normalize and compute inverse directions, 
        // As a side effect this also computes the sign mask for the box 
intersection.
-       rays.normalizeDirections();
+  rays.normalizeDirections();
        rays.computeInverseDirections();
        
        RayTriIntersectUserData isectData;
@@ -157,6 +180,7 @@
                        
                        // Send the ray to the _intersect function.
                        isectData.rayHitTriIndex = -1;
+      isectData.duplicate = 0;
                        intersect_node( rootNode, &e.ray, e, isectData, 
context, (float)minDist, (float)maxDist);
 
                }
@@ -194,15 +218,22 @@
                                                                              
                       float minDist, float maxDist) const
 {
        
-       // Keep a stack of entry and exit positions into the traversal nodes.
-       TravStackEntry travStack[128];
-       
+  // Mailbox for this traversal.
+  RayTriangleMailbox mailbox;
+  mailbox.clear();
+  
        KDTreeNode *nearNode, *farNode;
        float split;
        int axis, entryPos, exitPos;
        bool foundIntersection = false;
        int tmp;
-       
+
+  Pointf  origin    = ray->origin();
+  Vectorf direction = ray->direction();
+  
+  // Keep a stack of entry and exit positions into the traversal nodes.
+       __declspec(align(128)) TravStackEntry travStack[128];
+
        // Initialize the first two entries on the stack.
        entryPos = 0;
        nearNode = startNode;
@@ -210,13 +241,13 @@
        travStack[0].prev = 1;
        
        // Check for the case that the minimum intersection point is behind 
the origin.
-       travStack[entryPos].t = minDist < 0.0f ? 0.0 : minDist;
+       travStack[entryPos].t = minDist < 0.0f ? 0.0f : minDist;
        
        exitPos = 1;
        travStack[1].node = NULL;
        travStack[1].t = maxDist;
        travStack[1].prev = 0;
-       
+
        while (travStack[entryPos].prev) {
                
                // Traverse down until we find a leaf node.
@@ -228,11 +259,11 @@
                        split = nearNode->split();
                        
                        // Find where along the axis the ray enters and 
exits. 
-                       float entryPos_coord_on_axis = ray->origin()[axis] + 
-                                                       
travStack[entryPos].t*ray->direction()[axis];
+                       float entryPos_coord_on_axis = 
+                                                       
travStack[entryPos].t*direction[axis] + origin[axis];
                                                        
-                       float exitPos_coord_on_axis = ray->origin()[axis] + 
-                                                       
travStack[exitPos].t*ray->direction()[axis];
+                       float exitPos_coord_on_axis = 
+                                                       
travStack[exitPos].t*direction[axis] + origin[axis];
                        
                        // Check to see which side of the split the ray 
enters first.
                        if (entryPos_coord_on_axis <= split) {
@@ -272,28 +303,59 @@
                        // Update the far node.
                        // Specify a new exit node.
                        travStack[exitPos].node = farNode;
-                       travStack[exitPos].t = (split - ray->origin()[axis])* 
e.inverseDirection[axis];
+                       travStack[exitPos].t = (split - origin[axis])* 
e.inverseDirection[axis];
                        travStack[exitPos].prev = tmp;
                }
-               
-               // Check to see if we found a leaf node.
+
+               // Check to see if we found a non-empty leaf node.
                if (nearNode) {
                        
                        // Intersect the ray with a list of triangles.
-                       if (intersectTriangles(ray, nearNode->listBegin(), 
nearNode->listSize(), travStack[exitPos].t, &isectData, context) && 
+                       if (/*(nearNode->listSize() < 100) &&*/ 
+          intersectTriangles(ray, nearNode->listBegin(), 
nearNode->listSize(),
+                             /*travStack[exitPos].t,*/ e.hitInfo.minT(),
+                             &isectData,
+                             context, mailbox ) && 
                                        (isectData.rayHitTriIndex >= 0)) {
                                
-                               e.normal = normals[isectData.rayHitTriIndex];
+                               
                                
                                // Check against the hit record, Note that 
tex coord mapper is null.
-                               if (e.hitInfo.hit(isectData.rayHit.t, 
material, this, 0 )) {
-                                       
e.hitInfo.scratchpad<ScratchPadInfo>().normal  = 
normals[isectData.rayHitTriIndex];
-                                       
e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
tris->get(isectData.rayHitTriIndex).payload;
-                                       break;
-                               }
-                       }
+        if (e.hitInfo.hit(isectData.rayHit.t, material, this, 0 )) {
+
+          // if (isectData.rayHit.t > t_epsilon) {
+          // e.hitInfo.set_hit(isectData.rayHit.t, material, this, 0 );
+
+          // e.normal = normals[isectData.rayHitTriIndex];
+
+          e.hitInfo.scratchpad<ScratchPadInfo>().normal  = 
normals[isectData.rayHitTriIndex];
+#if SHOW_DUPLICATES
+          if (isectData.duplicate == 0)
+            e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
Color(RGB(1.0,1.0,1.0));
+          else if (isectData.duplicate > 16)
+            e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
Color(RGB(1.0,0.0,1.0));
+          else if (isectData.duplicate > 8)
+            e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
Color(RGB(1.0,0.0,0.0));
+          else if (isectData.duplicate > 4)
+            e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
Color(RGB(1.0,1.0,0.0));
+          else
+            e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
Color(RGB(0.0,0.0,1.0));
+#else          
+          e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
tris->get(isectData.rayHitTriIndex).payload;
+#endif
+          // Check to make sure the found hit is inside the current cell.
+          // if ((isectData.rayHit.t <= travStack[exitPos].t)/* && 
(isectData.rayHit.t > travStack[entryPos].t)*/)
+          // break;
+         }
+        }
                }
-               
+
+    // Check to see if the hit is inside the current cell.
+    if (e.hitInfo.minT() <= travStack[exitPos].t)
+      break;
+    
+    
+    
                // Move to the next 
                entryPos = exitPos;
                exitPos = travStack[exitPos].prev;

Modified: branches/itanium2/Model/Groups/KDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.h     (original)
+++ branches/itanium2/Model/Groups/KDTree.h     Thu Sep 29 12:59:23 2005
@@ -40,12 +40,13 @@
 
 #include <Interface/Texture.h>
 #include <Model/Groups/KDTreeLoader.h>
+#include <Model/Groups/RayTriangleMailbox.h>
 
-#define KDNODE_AXIS_MASK 0x0003
-#define KDNODE_INTERNAL_MASK 0x0004
-#define KDNODE_LEFT_CHILD_MASK 0x0008
+#define KDNODE_AXIS_MASK        0x0003
+#define KDNODE_INTERNAL_MASK    0x0004
+#define KDNODE_LEFT_CHILD_MASK  0x0008
 #define KDNODE_RIGHT_CHILD_MASK 0x0010
-#define KDNODE_CHILD_MASK 0x0030
+#define KDNODE_CHILD_MASK       0x0030
 
 #include "varray.h"
 
@@ -185,6 +186,12 @@
         return hasRightChild()?
           (hasLeftChild()?this+internal.left+1:this+internal.left) : 0;
       }
+
+      KDTreeNode *getChild( short int i ) {
+        return this + internal.left +
+          (i & ((internal.flags&KDNODE_LEFT_CHILD_MASK) >> 3));
+      };
+      
       float split()        const { return internal.split; }
       bool isInternal()    const {
         return internal.flags & KDNODE_INTERNAL_MASK;
@@ -256,6 +263,7 @@
       int rayHitTriIndex;
       RayHit_Triangle rayHit;
       float eyeToHitDist2;
+      int duplicate;
     };
 
     
///////////////////////////////////////////////////////////////////////////
@@ -294,7 +302,9 @@
       // This method intersects a list of triangles with the ray.
       int intersectTriangles(const Ray* ray, unsigned int listBegin,
                              int listSize, float maxDist, void *userData,
-                             const RenderContext &context) const;
+                             const RenderContext &context,
+                             RayTriangleMailbox &mailbox
+                             ) const;
 
       // This method is called to intersect a single ray with the kdtree.
 

Modified: branches/itanium2/Model/Groups/TransparentKDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.cc (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.cc Thu Sep 29 12:59:23 
2005
@@ -267,20 +267,23 @@
        Color &ray_color = e.hitInfo.scratchpad<ScratchPadInfo>().payload;
        Real  &ray_alpha = e.hitInfo.scratchpad<ScratchPadInfo>().alpha;
        
-       // Keep a stack of entry and exit positions into the traversal nodes.
-       TravStackEntry travStack[128];
-       
        KDTreeNode *nearNode, *farNode;
        float split;
        int axis, entryPos, exitPos;
        bool foundIntersection = false;
        int tmp;
        
+  Pointf  origin    = ray->origin();
+  Vectorf direction = ray->direction();
+  
+  // Keep a stack of entry and exit positions into the traversal nodes.
+       __declspec(align(128)) TravStackEntry travStack[128];
+       
        // Initialize the first two entries on the stack.
        entryPos = 0;
        nearNode = travStack[entryPos].node = rootNode; 
        travStack[entryPos].prev = 1;
-       travStack[entryPos].t = minDist < 0.0f ? 0 : minDist;
+       travStack[entryPos].t = minDist < 0.0f ? 0.0f : minDist;
        
        exitPos = 1;
        travStack[exitPos].node = NULL;
@@ -297,11 +300,11 @@
                        split = nearNode->split();
                        
                        // Find where along the axis the ray enters and 
exits. 
-                       float entryPos_coord_on_axis = ray->origin()[axis] + 
-                                                       
travStack[entryPos].t*ray->direction()[axis];
+                       float entryPos_coord_on_axis =  
+                                                       
travStack[entryPos].t*direction[axis] + origin[axis];
                                                        
-                       float exitPos_coord_on_axis = ray->origin()[axis] + 
-                                                       
travStack[exitPos].t*ray->direction()[axis];
+                       float exitPos_coord_on_axis = 
+                                                       
travStack[exitPos].t*direction[axis] + origin[axis];
                        
                        // Check to see which side of the split the ray 
enters first.
                        if (entryPos_coord_on_axis <= split) {
@@ -336,7 +339,7 @@
                        
                        // Specify a new exit node.
                        travStack[exitPos].node = farNode;
-                       travStack[exitPos].t = (split - ray->origin()[axis])* 
e.inverseDirection[axis];
+                       travStack[exitPos].t = (split - origin[axis])* 
e.inverseDirection[axis];
                        
                        travStack[exitPos].prev = tmp;
                }
@@ -379,7 +382,7 @@
        }
        
        // Blend with the background.
-       ray_color += (Color(RGB(0.8,0.8,0.8))) * (1.0 - ray_alpha);
+       ray_color += (Color(RGB(0.8,0.8,0.8))) * (1.0f - ray_alpha);
 }
 
 
///////////////////////////////////////////////////////////////////////////////

Modified: branches/itanium2/Model/Materials/LambertianAlt.cc
==============================================================================
--- branches/itanium2/Model/Materials/LambertianAlt.cc  (original)
+++ branches/itanium2/Model/Materials/LambertianAlt.cc  Thu Sep 29 12:59:23 
2005
@@ -28,25 +28,24 @@
        }
 #endif 
 
-#if 0  
+// #if 0       
        // Copy colors from hit info.
-       Color colors[RayPacket::MaxSize];
-       Real inv255 = 1.0/255.0;
-
+       
        for (int i=0;i<rays.getSize();i++) {
                RayPacket::Element& e = rays.get(i);
-               // colors[i] = 
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
-               
-               Vector &normal = 
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().normal;
-               
-               Real scale   = Abs(Dot(normal,e.ray.direction()));
-               scale = (scale * 0.5)+0.5;
-               
-               Color result = 
(e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload * scale);
+    
+               Color  &triangle_color = 
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
+               Vector &normal         = 
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().normal;
+
+    Real scale = Abs(Dot( normal, e.ray.direction() ));
+    scale *= 0.75;
+    scale += 0.25;
+    
+               Color result = (triangle_color * scale);
                
                rays.setResult( i, result );
        }
-#endif
+// #endif
 
 #if 0
        // Copy colors from hit info.
@@ -63,6 +62,7 @@
        }
 #endif 
 
+#if 0
        // Copy colors from hit info.
        Color colors[RayPacket::MaxSize];
        for(int i=0;i<rays.getSize();i++) {
@@ -120,5 +120,5 @@
                
                start = end;
        } while(start < rays.getSize());
-
+#endif
 }

Modified: branches/itanium2/StandAlone/frust-test.cc
==============================================================================
--- branches/itanium2/StandAlone/frust-test.cc  (original)
+++ branches/itanium2/StandAlone/frust-test.cc  Thu Sep 29 12:59:23 2005
@@ -21,7 +21,7 @@
 // These are the two main functions we will be testing
 #if 0
 // Intersect the specified frustum with an internal node.
-IntersectCase frustum_node_intersect(const RenderContext& context,
+IntersectCase frustum_node_intersect(
                                      const KDTreeNode *node,
                                      const PacketFrustum &frustum,
                                      const BBox &node_bounds );
@@ -73,7 +73,7 @@
   kdtree.debug_level = 1;
 
   FrustumKDTree::IntersectCase result =
-    kdtree.frustum_node_intersect(render_context, &node, pfrustum, bbox);
+    kdtree.frustum_node_intersect(/*render_context,*/ &node, pfrustum, bbox);
   switch(result) {
   case FrustumKDTree::INTERSECT_NONE:
     cout << "INTERSECT_NONE\n";

Modified: branches/itanium2/scenes/boeing777.cc
==============================================================================
--- branches/itanium2/scenes/boeing777.cc       (original)
+++ branches/itanium2/scenes/boeing777.cc       Thu Sep 29 12:59:23 2005
@@ -72,6 +72,7 @@
 using namespace SCIRun;
 
 enum CuttingPlaneType { CUTTING_NONE, CUTTING_DEFAULT, CUTTING_SPECIFIED };
+enum MtlType          { MTL_PHONG, MTL_LAMBERTIANALT, MTL_AMBIENT };
 
 ///////////////////////////////////////////////////////////////////////////
 // This function constructs the Boeing 777 Test Scene using a KdTree.
@@ -85,9 +86,17 @@
        
        CuttingPlaneType cutting_type = CUTTING_NONE;
        int workers_np = 1;
-       bool use_transparency = false;
-       double alpha = 1.0;
        
+  MtlType material_type = MTL_PHONG;
+  
+       double alpha = 1.0;
+  double ambient_dist = 5.0;
+  int    ambient_rays = 16;
+  int    phong_exp = 512;
+  double phong_reflect = 0.0;
+  
+  bool use_transparency = false;
+  
        // Parse args.i
        for (int i=0;i<args.size();++i) {
                if (args[i] == "-file") {
@@ -100,10 +109,28 @@
                                throw IllegalArgument("boeing777 -np <num 
build workers>", i, args);
                }
                else if (args[i] == "-alpha") {
+    
+      // Note this just specifies that a TransparentKDTree should be created 
as well.
+    
                        use_transparency = true;
                        if (!getDoubleArg(i, args, alpha ))
                                throw IllegalArgument("boeing777 -alpha 
<alpha>", i, args);
                }
+    else if (args[i] == "-lambertianalt") {
+      material_type = MTL_LAMBERTIANALT;
+    }
+    else if (args[i] == "-phong") {
+      material_type = MTL_PHONG;
+      if (!getIntArg(i, args, phong_exp) || !getDoubleArg(i, args, 
phong_reflect)) {
+        throw IllegalArgument("boeing777 -phong <exp> <reflection>", i, 
args);
+      }
+    }
+    else if (args[i] == "-ambient") {
+      material_type = MTL_AMBIENT;
+      if (!getDoubleArg(i, args, ambient_dist) || !getIntArg(i, args, 
ambient_rays)) {
+        throw IllegalArgument("boeing777 -ambient <max dist> <secondary 
rays>", i, args);
+      }
+    }
                else if (args[i] == "-cutting") {
                        string cutting_string;
                        if (getPointArg(i, args, plane_point ) && 
getVectorArg(i, args, plane_normal)) { 
@@ -121,7 +148,11 @@
                        cerr << "-file <filename>"             << endl;
                        cerr << "-np   <num build workers>"    << endl;
                        cerr << "-cutting [<point> <normal>]"  << endl;
-                       cerr << "-transparent"                 << endl;
+                       cerr << "-alpha <alpha>"               << endl;
+      cerr << "-lambertianalt (alpha=1.0 without transparent traversal)" << 
endl;
+      cerr << "-phong <exp> <reflection> **default**" << endl;
+      cerr << "-ambient <max dist> <secondary rays>"  << endl;
+      
                        throw IllegalArgument( "boeing777", i, args );
                }
        }
@@ -129,22 +160,28 @@
        // Create the scene.
        Scene *scene = new Scene();
        Object *root_object = 0;
-       
-       // Create a kd tree.
-       // KDTree *kdtree = new KDTree( new Lambertian( new KDTreeTexture ) );
-       
-  // #if 0     
-       KDTree *kdtree = new KDTree( new Phong( new KDTreeTexture, 
-                                               new 
Constant<Color>(Color::white()),
-                                                                             
                                                                              
            512,
-                                                                             
                                                                              
            new Constant<double>(0.0) ) );
-  // #endif
-#if 0
-       KDTree *kdtree = new KDTree( new AmbientOcclusion( new KDTreeTexture, 
-                                               new Constant<float>(5.0),
-                                                                             
                                                                              
            32 ) );                                                           
                                                                              
                
-#endif                                                                       
                                                                              
                    
-                                                                             
                                                                              
            
+
+  // Choose a material.
+  Material *kd_material = 0;
+  switch (material_type) {
+  case MTL_LAMBERTIANALT:
+    kd_material = new LambertianAlt;
+    break;
+  case MTL_AMBIENT:
+    kd_material = new AmbientOcclusion( new KDTreeTexture, 
+                                        new Constant<float>(ambient_dist),
+                                        ambient_rays );
+    break;
+  case MTL_PHONG:
+    kd_material = new Phong( new KDTreeTexture, 
+                             new Constant<Color>(Color::white()),
+                             phong_exp,
+                             new Constant<double>(phong_reflect) );
+    break;
+  };
+       
+       KDTree *kdtree = new KDTree( kd_material );
+                                                                             
                                                                              
                                    
        // KDTree *kdtree = new KDTree( new LambertianAlt );
        
        
/////////////////////////////////////////////////////////////////////////////
@@ -170,6 +207,7 @@
                transparent->setAlpha( alpha );
                kd_primitive = transparent;
        }
+  
        
        
////////////////////////////////////////////////////////////////////////////
        // Compute the middle of the model for a cutting plane.




  • [MANTA] r581 - in branches/itanium2: Engine/Control Interface Model/Groups Model/Materials StandAlone scenes, abe, 09/29/2005

Archive powered by MHonArc 2.6.16.

Top of page