Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r354 - in branches/itanium2: Engine/Shadows Model/Groups Model/Materials scenes


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r354 - in branches/itanium2: Engine/Shadows Model/Groups Model/Materials scenes
  • Date: Fri, 27 May 2005 15:43:03 -0600 (MDT)

Author: abe
Date: Fri May 27 15:43:01 2005
New Revision: 354

Modified:
   branches/itanium2/Engine/Shadows/HardShadows.cc
   branches/itanium2/Model/Groups/kdtree.cc
   branches/itanium2/Model/Groups/kdtree.h
   branches/itanium2/Model/Materials/LambertianAlt.cc
   branches/itanium2/scenes/boeing777.cc
Log:
Changed some lighting options etc

Modified: branches/itanium2/Engine/Shadows/HardShadows.cc
==============================================================================
--- branches/itanium2/Engine/Shadows/HardShadows.cc     (original)
+++ branches/itanium2/Engine/Shadows/HardShadows.cc     Fri May 27 15:43:01 
2005
@@ -23,12 +23,12 @@
 }
 
 int HardShadows::computeShadows(const RenderContext& context,
-                             const LightSet* lights, RayPacket& rays,
-                             int start, RayPacket& shadowRays)
+                                                                             
                                                  const LightSet* lights, 
RayPacket& rays,
+                                                                             
                                                  int start, RayPacket& 
shadowRays)
 {
   int nlights = lights->numLights();
   rays.computeHitPositions();
-
+       
   int sidx = 0;
   int end = start;
   while(end < rays.getSize() && sidx+nlights <= RayPacket::MaxSize){
@@ -37,16 +37,16 @@
     for(int l = 0;l<nlights;l++){
       Vector dir(lights->centers[l]-e.hitPosition);
       if(Dot(dir, e.normal)  > 0){
-       RayPacket::Element& s = shadowRays.get(sidx++);
-       double length = dir.normalize();
-       s.ray.set(e.hitPosition, dir);
-       s.light = lights->colors[l];
-       s.hitInfo.reset(length);
+                               RayPacket::Element& s = 
shadowRays.get(sidx++);
+                               double length = dir.normalize();
+                               s.ray.set(e.hitPosition+(e.normal*1e-5), dir);
+                               s.light = lights->colors[l];
+                               s.hitInfo.reset(length);
       }
     }
     e.shadowEnd = sidx;
   }
-
+       
   
shadowRays.setFlag(RayPacket::NormalizedDirections|RayPacket::HaveHitRecords);
   shadowRays.resize(sidx);
   if(end == start+1)

Modified: branches/itanium2/Model/Groups/kdtree.cc
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.cc    (original)
+++ branches/itanium2/Model/Groups/kdtree.cc    Fri May 27 15:43:01 2005
@@ -169,9 +169,6 @@
                fprintf(stderr, "Error reading file: %s Tris read: %ld; 
expected: %ld\n", filename, trisRead, nTris);
        }
 
-
-
-
        *tris = new VArray<Triangle> (nTris);
        (*tris)->setLen(nTris);
        *perVertNormals = new Vectorf [nTris*3];
@@ -286,6 +283,8 @@
 
        if (is_big_endian()) {
 
+               std::cout << "NOTE: This system is big endian and the boeing 
kdtree files are little, swapping bytes." << std::endl;
+
                rootNode->endian_swap();
                
                bboxf.min[0] = endian_swap( bboxf.min[0] );
@@ -298,6 +297,9 @@
                
        }
        bbox = BBox( bboxf.min, bboxf.max );
+       
+       // Output bounding box size.
+       std::cout << "Model bounds: min: " << bbox[0] << " max: " << bbox[1] 
<< std::endl;
        
        
/////////////////////////////////////////////////////////////////////////////
        // Load the index file

Modified: branches/itanium2/Model/Groups/kdtree.h
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.h     (original)
+++ branches/itanium2/Model/Groups/kdtree.h     Fri May 27 15:43:01 2005
@@ -75,6 +75,8 @@
                        int&    getPayload(int i) { return _payload->_get(i); 
}
                };
                        
+                       
+               
///////////////////////////////////////////////////////////////////////////
                // Swap the endianness of a variable.
                template< typename T >
                        T endian_swap( T in ) {
@@ -91,12 +93,10 @@
                        
                // Check the endianness of this machine.
                inline bool is_big_endian() {
+               
                        unsigned int x = 0x00112233;
-                       
                        char *p = (char *)&x;
-                       
-                       printf(">>%X\n",p[0]);
-                       
+               
                        return (p[0] == 0x00);
                }
                
@@ -243,6 +243,7 @@
                        void computeNormal(const RenderContext& context, 
RayPacket& rays) const;
                        void computeBounds(const PreprocessContext &context, 
BBox &box_ ) const { 
                                box_.extendByBox( bbox ); }
+                       void computeBounds( BBox &box_ ) const { 
box_.extendByBox( bbox ); }
                        
                        // This function is called to load the data.
                        int load(const char *fn);

Modified: branches/itanium2/Model/Materials/LambertianAlt.cc
==============================================================================
--- branches/itanium2/Model/Materials/LambertianAlt.cc  (original)
+++ branches/itanium2/Model/Materials/LambertianAlt.cc  Fri May 27 15:43:01 
2005
@@ -15,27 +15,21 @@
 
 void LambertianAlt::shade(const RenderContext& context, RayPacket& rays) 
const {
 
-       // for (int i=0;i<rays.getSize();++i) {
-       //      rays.setResult(i,Color(RGBColor(1.0,0.0,0.0)));
-       // }
 
-  // Shade a bunch of rays.  We know that they all have the same intersected
-  // object and are all of the same material
-
-  // Compute normals
-  // rays.computeNormals(context);
-
-  // Compute colors
+  // Copy colors from hit info.
   Color colors[RayPacket::MaxSize];
-  float inv255 = 1.0f/255.0f;
+  Real inv255 = 1.0/255.0;
+       
   for (int i=0;i<rays.getSize();i++) {
       RayPacket::Element& e = rays.get(i);
       unsigned int rgb = 
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
+                       
       colors[i] = Color(RGBColor(((rgb & 0xFF0000) >> 16)*inv255,
                                             ((rgb & 0x00FF00) >>  8)*inv255,
                                             ((rgb & 0x0000FF) >>  
0)*inv255));
   }
 
+#if 0
        for(int i=0;i<rays.getSize();i++) {
                RayPacket::Element& e = rays.get(i);
                float z = SCIRun::Abs(e.normal[2]);
@@ -43,6 +37,7 @@
                rays.setResult(i, colors[i]*totalLight);
        }
        return;
+#endif
 
   Scene *scene = (Scene*)context.scene;
   
@@ -54,37 +49,39 @@
 
   RayPacketData data;
   int start = 0;
+
   do {
     RayPacket shadowRays(data, 0, rays.getDepth(), 0);
+               
+               // Send the shadow ray.
     int end = context.shadowAlgorithm->computeShadows(context, 
scene->getLights(), rays, start, shadowRays);
-    if(shadowRays.getFlags() & RayPacket::NormalizedDirections){
-      for(int i=start;i<end;i++){
-                               RayPacket::Element& e = rays.get(i);
-                               Color totalLight(e.ambientLight);
-                               for(int j=e.shadowBegin;j<e.shadowEnd;j++){
-                                       RayPacket::Element& s = 
shadowRays.get(j);
-                                       if(!s.hitInfo.wasHit()){
-                                               double cos_theta = 
Dot(s.ray.direction(), e.normal);
-                                               totalLight += 
s.light*cos_theta;
-                                       }
+
+               // Normalize the shadow ray directions.
+               shadowRays.normalizeDirections();
+               
+               // Iterate over the ray packet.
+               for(int i=start;i<end;i++){
+                       RayPacket::Element& e = rays.get(i);
+                       
+                       Color totalLight(e.ambientLight);
+                       
+                       // Iterate over the shadow ray packet for this ray 
(Is this usually one??) 
+                       for(int j=e.shadowBegin;j<e.shadowEnd;j++){
+                               RayPacket::Element& s = shadowRays.get(j);
+                               
+                               // Check to see if the shadow ray hit 
something.
+                               if(!s.hitInfo.wasHit()){
+                                       double cos_theta = 
Dot(s.ray.direction(), e.normal);
+                                       totalLight += s.light*cos_theta;
                                }
-                               rays.setResult(i, colors[i]*totalLight);
+                               
                        }
-    } else {
-      for(int i=start;i<end;i++){
-                               RayPacket::Element& e = rays.get(i);
-                               Color totalLight(e.ambientLight);
-                               for(int j=e.shadowBegin;j<e.shadowEnd;j++){
-                                       RayPacket::Element& s = 
shadowRays.get(j);
-                                       if(!s.hitInfo.wasHit()){
-                                               s.ray.normalizeDirection();
-                                               double cos_theta = 
Dot(s.ray.direction(), e.normal);
-                                               totalLight += 
s.light*cos_theta;
-                                       }
-                               }
-                               rays.setResult(i, colors[i]*totalLight);
-      }
-    }
+                       
+                       // Set the result..
+                       rays.setResult(i, colors[i]*totalLight);
+               }
+               
     start = end;
   } while(start < rays.getSize());
+
 }

Modified: branches/itanium2/scenes/boeing777.cc
==============================================================================
--- branches/itanium2/scenes/boeing777.cc       (original)
+++ branches/itanium2/scenes/boeing777.cc       Fri May 27 15:43:01 2005
@@ -56,20 +56,31 @@
   Scene *scene = new Scene();
 
   // Create a kd tree.
-  KDTree *world = new KDTree;
-  world->load( file_name.c_str() );
+  KDTree *kdtree = new KDTree;
+  kdtree->load( file_name.c_str() );
        
+       // Determine the bounds of the model.
+       BBox bounds;
+       kdtree->computeBounds( bounds );
+       
+       // Compute the height of a light above the scene.
+       Real light_height = bounds.diagonal().maxComponent();
+       Point light_position = bounds.center() + Vector(0,0,light_height);
+       
+       std::cout << "Adding light above scene: position: " << light_position 
<< std::endl;
+       
+       // Add a light.
   LightSet* lights = new LightSet();
-  lights->add(new PointLight(Point(0,0,8), Color(RGBColor(.6,.1,.1))));
-  lights->setAmbientLight(new ConstantAmbient(Color::black()));
-  
+  lights->add( new PointLight(light_position, Color(RGBColor(0.9,0.9,0.9) 
)));
+  lights->setAmbientLight( new ConstantAmbient( Color(RGBColor(0.3,0.3,0.3) 
) ));
        scene->setLights(lights);
 
   // Add the tree to the scene.
-  scene->setObject( world );
+  scene->setObject( kdtree );
 
   // Set other important scene properties.
-  
+  // ...?
+       
   // Background.
   scene->setBackground( new ConstantBackground(Color(RGB(0.8, 0.8, 0.8))) );
 




  • [MANTA] r354 - in branches/itanium2: Engine/Shadows Model/Groups Model/Materials scenes, abe, 05/27/2005

Archive powered by MHonArc 2.6.16.

Top of page