Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r808 - in branches/vertical: Core/Color Core/Geometry Engine/Shadows Model/Materials StandAlone


Chronological Thread 
  • From: sparker@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r808 - in branches/vertical: Core/Color Core/Geometry Engine/Shadows Model/Materials StandAlone
  • Date: Wed, 28 Dec 2005 14:27:14 -0700 (MST)

Author: sparker
Date: Wed Dec 28 14:27:13 2005
New Revision: 808

Modified:
   branches/vertical/Core/Color/ColorSpace.h
   branches/vertical/Core/Geometry/PointVector.h
   branches/vertical/Engine/Shadows/HardShadows.cc
   branches/vertical/Engine/Shadows/NoShadows.cc
   branches/vertical/Model/Materials/Phong.cc
   branches/vertical/StandAlone/manta.cc
Log:
A few cleanups
Fixed bugs in new shadow code.  Still around the same speed as before on
the basic scene, but it should be faster on more complex scenes with
multiple light sources.


Modified: branches/vertical/Core/Color/ColorSpace.h
==============================================================================
--- branches/vertical/Core/Color/ColorSpace.h   (original)
+++ branches/vertical/Core/Color/ColorSpace.h   Wed Dec 28 14:27:13 2005
@@ -15,7 +15,6 @@
   class ColorSpace {
   public:
     typedef typename Traits::ComponentType ComponentType;
-    typedef typename Traits::ComponentType ScalarType;
     enum { NumComponents = Traits::NumComponents};
 
     ColorSpace() { }

Modified: branches/vertical/Core/Geometry/PointVector.h
==============================================================================
--- branches/vertical/Core/Geometry/PointVector.h       (original)
+++ branches/vertical/Core/Geometry/PointVector.h       Wed Dec 28 14:27:13 
2005
@@ -24,7 +24,7 @@
   template<typename T, int Dim> 
     class VectorT {
   public:
-                       typedef T ScalarType;
+    typedef T ComponentType;
                        
     VectorT() {
     }

Modified: branches/vertical/Engine/Shadows/HardShadows.cc
==============================================================================
--- branches/vertical/Engine/Shadows/HardShadows.cc     (original)
+++ branches/vertical/Engine/Shadows/HardShadows.cc     Wed Dec 28 14:27:13 
2005
@@ -24,7 +24,7 @@
 
 bool HardShadows::computeShadows(const RenderContext& context,
                                  const LightSet* lights, 
-                                 RayPacket& rays,              // Input rays.
+                                 RayPacket& sourceRays,        // Input rays.
                                  int map[],                    // map from 
shadow rays to input rays
                                  RayPacket& shadowRays,        // Output 
shadow rays, already intersected.
                                  bool firstTime,
@@ -33,13 +33,13 @@
   int nlights = lights->numLights();
   
   // Compute the hit positions.
-  rays.computeHitPositions();
-  rays.computeNormals( context );
+  sourceRays.computeHitPositions();
+  sourceRays.computeNormals( context );
 
   int sidx = 0;
   int starti, j;
   if(firstTime){
-    starti = rays.begin();
+    starti = sourceRays.begin();
     j = 0;
   } else {
     starti = stateBuffer.i1;
@@ -50,33 +50,46 @@
     // Compute the contribution for this light.
     Color lightColors[RayPacket::MaxSize];
     Vector lightDirections[RayPacket::MaxSize];
-    lights->getLight(j)->computeLight( lightColors, lightDirections, 
context, rays);
+    lights->getLight(j)->computeLight( lightColors, lightDirections, 
context, sourceRays);
 
-    for(int i = starti; i < rays.end(); i++){
+    for(int i = starti; i < sourceRays.end(); i++){
       // Check to see if the light is on the front face.
       Vector dir = lightDirections[i];
-      if(Dot(dir, rays.getNormal(i)) > 0) {
+      if(Dot(dir, sourceRays.getNormal(i)) > 0) {
 
         // If so normalize and compute length.
         Real length = dir.normalize();
        
         // Populate the shadow ray.
-        shadowRays.setRay(sidx, rays.getHitPosition(i), dir );
+        shadowRays.setRay(sidx, sourceRays.getHitPosition(i), dir );
         shadowRays.setResult(sidx, lightColors[i]);
         shadowRays.resetHit( sidx, length );
-        sidx++;
-      }
-
-      if(++sidx >= RayPacket::MaxSize && (j != nlights || i != rays.end())){
-        stateBuffer.i1 = i;
-        stateBuffer.i2 = j;
-        done = false;
-        j = nlights; // To break out of outer loop after we compute the 
light source contributions
+        map[sidx] = i;
+        if(++sidx >= RayPacket::MaxSize){
+          if(i+1 == sourceRays.end()){
+            if(j+1 == nlights){
+              // Do nothing - we are done
+            } else {
+              // Save our position but start on the next light
+              stateBuffer.i1 = sourceRays.begin();
+              stateBuffer.i2 = j+1;
+              done = false;
+            }
+          } else {
+            stateBuffer.i1 = i+1;
+            stateBuffer.i2 = j;
+            done = false;
+          }
+          // Okay, a goto is nasty, but C++ doesn't have "break 2" and we 
need to get
+          // out of this loop without too much extra work
+          goto break2;
+        }
       }
     }
     
-    starti = 0;
+    starti = sourceRays.begin();
   }
+ break2:
       
   // Send the shadow rays.
   shadowRays.setFlag( 
RayPacket::NormalizedDirections|RayPacket::HaveHitRecords );

Modified: branches/vertical/Engine/Shadows/NoShadows.cc
==============================================================================
--- branches/vertical/Engine/Shadows/NoShadows.cc       (original)
+++ branches/vertical/Engine/Shadows/NoShadows.cc       Wed Dec 28 14:27:13 
2005
@@ -25,13 +25,14 @@
 {
   int nlights = lights->numLights();
   
-  // Compute the hit normals
-  rays.computeNormals( context );
+  // Compute the hit positions.
+  sourceRays.computeHitPositions();
+  sourceRays.computeNormals( context );
 
   int sidx = 0;
   int starti, j;
   if(firstTime){
-    starti = rays.begin();
+    starti = sourceRays.begin();
     j = 0;
   } else {
     starti = stateBuffer.i1;
@@ -42,30 +43,48 @@
     // Compute the contribution for this light.
     Color lightColors[RayPacket::MaxSize];
     Vector lightDirections[RayPacket::MaxSize];
-    lights->getLight(j)->computeLight( lightColors, lightDirections, 
context, rays);
+    lights->getLight(j)->computeLight( lightColors, lightDirections, 
context, sourceRays);
 
-    for(int i = starti; i < rays.end(); i++){
+    for(int i = starti; i < sourceRays.end(); i++){
       // Check to see if the light is on the front face.
       Vector dir = lightDirections[i];
-      if(Dot(dir, rays.getNormal(i)) > 0) {
-        // Populate the shadow ray.
+      if(Dot(dir, sourceRays.getNormal(i)) > 0) {
+
+        // If so normalize and compute length.
+        Real length = dir.normalize();
+       
+        // Populate the direction and color only
         shadowRays.setDirection(sidx, dir );
         shadowRays.setResult(sidx, lightColors[i]);
-        sidx++;
-      }
-
-      if(++sidx >= RayPacket::MaxSize && (j != nlights || i != rays.end())){
-        stateBuffer.i1 = i;
-        stateBuffer.i2 = j;
-        done = false;
-        j = nlights; // To break out of outer loop after we compute the 
light source contributions
+        map[sidx] = i;
+        if(++sidx >= RayPacket::MaxSize){
+          if(i+1 == sourceRays.end()){
+            if(j+1 == nlights){
+              // Do nothing - we are done
+            } else {
+              // Save our position but start on the next light
+              stateBuffer.i1 = sourceRays.begin();
+              stateBuffer.i2 = j+1;
+              done = false;
+            }
+          } else {
+            stateBuffer.i1 = i+1;
+            stateBuffer.i2 = j;
+            done = false;
+          }
+          // Okay, a goto is nasty, but C++ doesn't have "break 2" and we 
need to get
+          // out of this loop without too much extra work
+          goto break2;
+        }
       }
     }
     
-    starti = 0;
+    starti = sourceRays.begin();
   }
+ break2:
       
-  shadowRays.resize ( sidx );  
+  shadowRays.resize ( sidx );
+  shadowRays.resetHits();
   return done;
 }
 

Modified: branches/vertical/Model/Materials/Phong.cc
==============================================================================
--- branches/vertical/Model/Materials/Phong.cc  (original)
+++ branches/vertical/Model/Materials/Phong.cc  Wed Dec 28 14:27:13 2005
@@ -82,6 +82,7 @@
   ShadowAlgorithm::StateBuffer stateBuffer;
   bool firstTime = true;
   bool done;
+  int count = 0;
   do {
     RayPacket shadowRays(shadowData, 0, 0, rays.getDepth(), 0);
 
@@ -125,7 +126,7 @@
   for(int i = rays.begin(); i < rays.end(); i++){
     Color result;
     for(int j=0;j<Color::NumComponents;j++)
-      result[j] = specularLight[j][i] * specular[j][i] + 
ambientAndDiffuseLight[j][i] * diffuse[j][i];
+      result[j] = specularLight[j][i] * specular[i][j] + 
ambientAndDiffuseLight[j][i] * diffuse[i][j];
     rays.setResult(i, result);
   }
 

Modified: branches/vertical/StandAlone/manta.cc
==============================================================================
--- branches/vertical/StandAlone/manta.cc       (original)
+++ branches/vertical/StandAlone/manta.cc       Wed Dec 28 14:27:13 2005
@@ -347,9 +347,7 @@
 #include <Model/Lights/PointLight.h>
 #include <Model/Textures/Constant.h>
 #include <Model/Textures/CheckerTexture.h>
-//#include <Model/Textures/MarbleTexture.h>
 #include <Model/Materials/Phong.h>
-//#include <Model/Materials/Flat.h>
 #include <Model/Groups/Group.h>
 #include <Model/Primitives/Parallelogram.h>
 #include <Model/Primitives/Sphere.h>
@@ -358,7 +356,8 @@
 Scene* createDefaultScene()
 {
   // Create a default scene.  This scene is used for benchmarks, so
-  // please do not change it.  Please create a new scene instead
+  // please do not change it.  Please create a new scene instead.
+  // Don't even put any #ifdefs in it or code that is commented out.
   Scene* scene = new Scene();
 
   scene->setBackground(new 
ConstantBackground(ColorDB::getNamedColor("SkyBlue3")*0.5));




  • [MANTA] r808 - in branches/vertical: Core/Color Core/Geometry Engine/Shadows Model/Materials StandAlone, sparker, 12/28/2005

Archive powered by MHonArc 2.6.16.

Top of page