Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r798 - in branches/vertical: Engine/PixelSamplers Engine/Renderers Engine/Shadows Interface Model/AmbientLights Model/Lights Model/Materials StandAlone


Chronological Thread 
  • From: sparker@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r798 - in branches/vertical: Engine/PixelSamplers Engine/Renderers Engine/Shadows Interface Model/AmbientLights Model/Lights Model/Materials StandAlone
  • Date: Tue, 20 Dec 2005 17:09:37 -0700 (MST)

Author: sparker
Date: Tue Dec 20 17:09:36 2005
New Revision: 798

Modified:
   branches/vertical/Engine/PixelSamplers/JitterSampler.cc
   branches/vertical/Engine/Renderers/Raytracer.cc
   branches/vertical/Engine/Shadows/HardShadows.cc
   branches/vertical/Engine/Shadows/NoShadows.cc
   branches/vertical/Interface/AmbientLight.h
   branches/vertical/Interface/Light.h
   branches/vertical/Interface/RayPacket.h
   branches/vertical/Model/AmbientLights/ConstantAmbient.cc
   branches/vertical/Model/AmbientLights/ConstantAmbient.h
   branches/vertical/Model/Lights/PointLight.cc
   branches/vertical/Model/Lights/PointLight.h
   branches/vertical/Model/Materials/Phong.cc
   branches/vertical/StandAlone/manta.cc
Log:
More progress on vertical raypackets - it sort of works...


Modified: branches/vertical/Engine/PixelSamplers/JitterSampler.cc
==============================================================================
--- branches/vertical/Engine/PixelSamplers/JitterSampler.cc     (original)
+++ branches/vertical/Engine/PixelSamplers/JitterSampler.cc     Tue Dec 20 
17:09:36 2005
@@ -202,7 +202,7 @@
             // the RayPacket again.
             sample_count = 0;
             // Make sure we start with a fresh slate
-            rays.resetHit();
+            rays.resetHits();
             rays.setAllFlags(flags);
           }
         } // end sample filling loops

Modified: branches/vertical/Engine/Renderers/Raytracer.cc
==============================================================================
--- branches/vertical/Engine/Renderers/Raytracer.cc     (original)
+++ branches/vertical/Engine/Renderers/Raytracer.cc     Tue Dec 20 17:09:36 
2005
@@ -48,7 +48,7 @@
 
 void Raytracer::traceRays(const RenderContext& context, RayPacket& rays)
 {
-  rays.resetHit();
+  rays.resetHits();
   context.scene->getObject()->intersect(context, rays);
 
   // Go through the ray packet and shade them.  Group rays that hit the

Modified: branches/vertical/Engine/Shadows/HardShadows.cc
==============================================================================
--- branches/vertical/Engine/Shadows/HardShadows.cc     (original)
+++ branches/vertical/Engine/Shadows/HardShadows.cc     Tue Dec 20 17:09:36 
2005
@@ -23,16 +23,16 @@
 }
 
 int HardShadows::computeShadows(const RenderContext& context,
-                                                                             
                                                  const LightSet* lights, 
-                                                                             
                                                  RayPacket& rays,            
  // Input rays.
-                                                                             
                                                  int start,                  
  // Offset to start from in input rays?
-                                                                             
                                                  RayPacket& shadow_rays)     
  // Output shadow rays, already intersected.
+                                const LightSet* lights, 
+                                RayPacket& rays,              // Input rays.
+                                int start,                    // Offset to 
start from in input rays?
+                                RayPacket& shadowRays)       // Output 
shadow rays, already intersected.
 {
   int nlights = lights->numLights();
   
-       // Compute the hit positions.
-       rays.computeHitPositions();
-       rays.computeNormals( context );
+  // Compute the hit positions.
+  rays.computeHitPositions();
+  rays.computeNormals( context );
        
 #if 0
        // Construct a shadow ray packet.
@@ -63,17 +63,17 @@
                
                // Set the shadow ray.
                for (int i=0; ((shadow_i+i)<RayPacket::MaxSize) && 
(i<rays.getSize();++i) {
-                       shadow_rays.get(shadow_i+i).ray.set( 
rays[i].hitPosition, direction[i] );
+                       shadowRays.get(shadow_i+i).ray.set( 
rays[i].hitPosition, direction[i] );
                }
                
                // Copy the light contribution.
                for (int i=0; ((shadow_i+i)<RayPacket::MaxSize) && 
(i<rays.getSize();++i) {             
-                       shadow_rays.get(shadow_i+i).light = 
lights[light].color;
+                       shadowRays.get(shadow_i+i).light = 
lights[light].color;
                }       
                
                // Copy the distance.
                for (int i=0; ((shadow_i+i)<RayPacket::MaxSize) && 
(i<rays.getSize();++i) {
-                       shadow_rays.get(shadow_i+i).hitInfo.reset( 
distance[i] );
+                       shadowRays.get(shadow_i+i).hitInfo.reset( distance[i] 
);
                }
                
                // Move to the next part of the shadow ray packet.
@@ -83,13 +83,10 @@
 
   int sidx = 0;
   int end = start;
-#if 0
   while(end < rays.getSize() && sidx+nlights <= RayPacket::MaxSize){
 
-    RayPacket::Element& e = rays.get(end++);
-
     // Specify the beginning index for this ray in the shadow packet.
-    e.shadowBegin = sidx;
+    rays.setShadowBegin(end, sidx);
 
     // Iterate over the lights and create shadow rays.
     for(int l=0;l<nlights;l++){
@@ -98,34 +95,34 @@
       Color  color;
                
       // Compute the contribution for this light.
-      lights->getLight(l)->computeLight( color, dir, context, e );
+      lights->getLight(l)->computeLight( color, dir, context, rays, end);
       
       // Check to see if the light is on the front face.
-      if(Dot(dir, e.normal) > 0) {
+      if(Dot(dir, rays.getNormal(end)) > 0) {
                        
         // If so normalize and compute length.
         Real length = dir.normalize();
        
         // Populate the shadow ray.
-        RayPacket::Element& s = shadow_rays.get(sidx++);
-        s.ray.set( e.hitPosition, dir );
-        s.light = color;
-        s.hitInfo.reset( length );
+        shadowRays.setRay(sidx, rays.getHitPosition(end), dir );
+        shadowRays.setLight(sidx, color);
+        shadowRays.resetHit( sidx, length );
+        sidx++;
       }
     }
-    e.shadowEnd = sidx;
+    rays.setShadowEnd(end, sidx);
+    end++;
   }
-#endif
        
   // Send the shadow rays.
-  shadow_rays.setFlag( 
RayPacket::NormalizedDirections|RayPacket::HaveHitRecords );
-  shadow_rays.resize ( sidx );
+  shadowRays.setFlag( 
RayPacket::NormalizedDirections|RayPacket::HaveHitRecords );
+  shadowRays.resize ( sidx );
        
   // Check to see if all of the shadow rays start from the same input ray.
   if(end == start+1)
-    shadow_rays.setFlag( RayPacket::ConstantOrigin );
+    shadowRays.setFlag( RayPacket::ConstantOrigin );
   
-  context.scene->getObject()->intersect(context, shadow_rays);
+  context.scene->getObject()->intersect(context, shadowRays);
        
   return end;
 }

Modified: branches/vertical/Engine/Shadows/NoShadows.cc
==============================================================================
--- branches/vertical/Engine/Shadows/NoShadows.cc       (original)
+++ branches/vertical/Engine/Shadows/NoShadows.cc       Tue Dec 20 17:09:36 
2005
@@ -20,43 +20,38 @@
 }
 
 int NoShadows::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;
-#if 0
   while(start < rays.getSize() && sidx+nlights < RayPacket::MaxSize){
-    RayPacket::Element& e = rays.get(start++);
-    e.shadowBegin = sidx;
+    rays.setShadowBegin(start, sidx);
     for(int l = 0;l<nlights;l++){
       Color color;
       Vector dir;
                
       // Compute the direction & color of this light.
-      lights->getLight(l)->computeLight(color,dir,context,e);
+      lights->getLight(l)->computeLight(color,dir,context,rays, start);
                
-      // Construct the shadow ray.
-      RayPacket::Element& s = shadowRays.get(sidx);
-                       
-      if(Dot(dir, e.normal)  > 0){
-        sidx++;
+      if(Dot(dir, rays.getNormal(start))  > 0){
         // Be sure to normalize the normals
-        s.ray.setDirection(dir.normal());
-        s.light = color;
+        shadowRays.setDirection(sidx, dir.normal());
+        shadowRays.setLight(sidx, color);
+        sidx++;
       }
     }
-    e.shadowEnd = sidx;
+    rays.setShadowEnd(start, sidx);
+    start++;
   }
-#endif
 
   // We already normalized the rays, so indicate that so we don't do
   // redundant work.
   shadowRays.setFlag( RayPacket::NormalizedDirections );
   shadowRays.resize(sidx);
-  shadowRays.resetHit();
+  shadowRays.resetHits();
   return start;
 }
 

Modified: branches/vertical/Interface/AmbientLight.h
==============================================================================
--- branches/vertical/Interface/AmbientLight.h  (original)
+++ branches/vertical/Interface/AmbientLight.h  Tue Dec 20 17:09:36 2005
@@ -6,7 +6,6 @@
 #include <sgi_stl_warnings_off.h>
 #include <string>
 #include <sgi_stl_warnings_on.h>
-#include <Interface/RayPacket.h>
 
 namespace Manta {
   class PreprocessContext;
@@ -18,7 +17,7 @@
     virtual ~AmbientLight();
 
     virtual void preprocess(const PreprocessContext& context) = 0;
-    virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays, ColorArray result) const = 0;
+    virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays) const = 0;
 
     // This function will return a newly allocated pointer of a string
     // representation of the object.  You should delete it yourself.

Modified: branches/vertical/Interface/Light.h
==============================================================================
--- branches/vertical/Interface/Light.h (original)
+++ branches/vertical/Interface/Light.h Tue Dec 20 17:09:36 2005
@@ -20,25 +20,22 @@
     // virtual const Point& getCenter() const = 0;
     // virtual const Color& getColor() const = 0;
 
-#if 0          
-               // This method is called on the light by the shadow 
algorithm. The color and direction 
-               // produced by the light may change for each ray in the 
packet, and may change based 
-               // on the render context.
-               virtual void computeLight( Real   
lightDistance[RayPacket::MaxSize], 
-                                          Color  
resultColor[RayPacket::MaxSize], 
-                                                                             
                               Vector lightDirection[RayPacket::MaxSize], 
-                                                                             
                           
-                                                                             
                           RenderContext &context, RayPacket &rays ) = 0;
+#if 0
+    // This method is called on the light by the shadow algorithm. The color 
and direction 
+    // produced by the light may change for each ray in the packet, and may 
change based 
+    // on the render context.
+    virtual void computeLight( Real   lightDistance[RayPacket::MaxSize], 
+                               Color  resultColor[RayPacket::MaxSize], 
+                               Vector lightDirection[RayPacket::MaxSize], 
+                               RenderContext &context, RayPacket &rays, int 
which ) = 0;
 #endif
 
-#if 0
-               // This method is called on the light by the shadow algorithm 
to compute
-               // the direction and contribution for one ray packet element.
-               // The direction is not normalized and the distance to the 
light from 
-               // the intersection must be computed.
-               virtual void computeLight( Color &resultColor, Vector 
&lightDirection,
-                                          const RenderContext &context, 
RayPacket::Element &e ) const = 0;
-#endif 
+    // This method is called on the light by the shadow algorithm to compute
+    // the direction and contribution for one ray packet element.
+    // The direction is not normalized and the distance to the light from 
+    // the intersection must be computed.
+    virtual void computeLight( Color &resultColor, Vector &lightDirection,
+                               const RenderContext &context, RayPacket &e, 
int which ) const = 0;
   private:
                // Lights may not be copied.
     Light( const Light & );

Modified: branches/vertical/Interface/RayPacket.h
==============================================================================
--- branches/vertical/Interface/RayPacket.h     (original)
+++ branches/vertical/Interface/RayPacket.h     Tue Dec 20 17:09:36 2005
@@ -48,6 +48,12 @@
 
     // Char-based arrays
     char scratchpad_data[Size][MaxScratchpadSize];
+
+    // Temporarily here but will go when I redo the lighting...
+    Color::ComponentType ambientLight[Color::NumComponents][Size];
+    Color::ComponentType light[Color::NumComponents][Size];
+    int shadowBegin[Size];
+    int shadowEnd[Size];
   };
 
   typedef Color::ComponentType 
ColorArray[Color::NumComponents][RayPacketData::Size];
@@ -129,13 +135,17 @@
     int getSize() const {
       return end-start;
     }
-    void resetHit() {
+    void resetHits() {
       for(int i=start;i<end;i++){
         data->hitMatl[i] = 0;
         data->minT[i] = MAXT;
       }
       flags |= HaveHitRecords;
     }
+    void resetHit(int which, Real maxt) {
+      data->hitMatl[which+start] = 0;
+      data->minT[which+start] = maxt;
+    }
 
     void resize(int newSize)
     {
@@ -144,92 +154,138 @@
 
     void setPixel(int which, int whichEye, Real imageX, Real imageY)
     {
-      data->image[0][which] = imageX;
-      data->image[1][which] = imageY;
-      data->whichEye[which] = whichEye;
+      data->image[0][which+start] = imageX;
+      data->image[1][which+start] = imageY;
+      data->whichEye[which+start] = whichEye;
     }
 
     void setResult(int which, const Color& color)
     {
       for(int i=0;i<Color::NumComponents;i++)
-        data->color[i][which] = color[i];
+        data->color[i][which+start] = color[i];
     }
     void setImportance(int which, const Color& importance)
     {
       for(int i=0;i<Color::NumComponents;i++)
-        data->importance[i][which] = importance[i];
+        data->importance[i][which+start] = importance[i];
     }
     Color getImportance(int which)
     {
       Color result;
       for(int i=0;i<Color::NumComponents;i++)
-        result[i] = data->importance[i][which];
+        result[i] = data->importance[i][which+start];
+      return result;
+    }
+
+    void setAmbientLight(int which, const Color& ambientLight)
+    {
+      for(int i=0;i<Color::NumComponents;i++)
+        data->ambientLight[i][which+start] = ambientLight[i];
+    }
+    Color getAmbientLight(int which)
+    {
+      Color result;
+      for(int i=0;i<Color::NumComponents;i++)
+        result[i] = data->ambientLight[i][which+start];
+      return result;
+    }
+    void setLight(int which, const Color& light)
+    {
+      for(int i=0;i<Color::NumComponents;i++)
+        data->light[i][which+start] = light[i];
+    }
+    Color getLight(int which)
+    {
+      Color result;
+      for(int i=0;i<Color::NumComponents;i++)
+        result[i] = data->light[i][which+start];
       return result;
     }
+    int shadowBegin(int which)
+    {
+      return data->shadowBegin[which+start];
+    }
+    int shadowEnd(int which)
+    {
+      return data->shadowEnd[which+start];
+    }
+    void setShadowBegin(int which, int s)
+    {
+      data->shadowBegin[which+start] = s;
+    }
+    void setShadowEnd(int which, int s)
+    {
+      data->shadowEnd[which+start] = s;
+    }
 
     Real getImageCoordinates(int which, int dim)
     {
-      return data->image[dim][which];
+      return data->image[dim][which+start];
     }
     int getWhichEye(int which) const
     {
-      return data->whichEye[which];
+      return data->whichEye[which+start];
     }
 
     void setRay(int which, const Point& origin, const Vector& direction)
     {
       for(int i=0;i<3;i++)
-        data->origin[i][which] = origin[i];
+        data->origin[i][which+start] = origin[i];
+      for(int i=0;i<3;i++)
+        data->direction[i][which+start] = direction[i];
+    }
+    void setDirection(int which, const Vector& direction)
+    {
       for(int i=0;i<3;i++)
-        data->direction[i][which] = direction[i];
+        data->direction[i][which+start] = direction[i];
     }
     void setTexCoords(int which, const Point& tc)
     {
       for(int i=0;i<3;i++)
-        data->texCoords[i][which] - tc[i];
+        data->texCoords[i][which+start] - tc[i];
     }
 
     Point getTexCoords(int which) const
     {
-      return Point(data->texCoords[0][which], data->texCoords[1][which], 
data->texCoords[2][which]);
+      return Point(data->texCoords[0][which+start], 
data->texCoords[1][which+start], data->texCoords[2][which+start]);
     }
 
     void setNormal(int which, const Vector& normal)
     {
       for(int i=0;i<3;i++)
-        data->normal[i][which] = normal[i];
+        data->normal[i][which+start] = normal[i];
     }
 
     Point getOrigin(int which) const
     {
-      return Point(data->origin[0][which], data->origin[1][which], 
data->origin[2][which]);
+      return Point(data->origin[0][which+start], 
data->origin[1][which+start], data->origin[2][which+start]);
     }
     Vector getDirection(int which) const
     {
-      return Vector(data->direction[0][which], data->direction[1][which], 
data->direction[2][which]);
+      return Vector(data->direction[0][which+start], 
data->direction[1][which+start], data->direction[2][which+start]);
     }
     Real getMinT(int which) const
     {
-      return data->minT[which];
+      return data->minT[which+start];
     }
     Vector getNormal(int which) const
     {
-      return Vector(data->normal[0][which], data->normal[1][which], 
data->normal[2][which]);
+      return Vector(data->normal[0][which+start], 
data->normal[1][which+start], data->normal[2][which+start]);
     }
     Point getHitPosition(int which) const
     {
-      return Point(data->hitPosition[0][which], data->hitPosition[1][which], 
data->hitPosition[2][which]);
+      return Point(data->hitPosition[0][which+start], 
data->hitPosition[1][which+start], data->hitPosition[2][which+start]);
     }
 
     bool hit(int which, Real t, const Material* matl, const Primitive* prim,
              const TexCoordMapper* tex) {
       if(t < (Real)T_EPSILON)
         return false;
-      if(t < data->minT[which]){
-        data->minT[which] = t;
-        data->hitMatl[which] = matl;
-        data->hitPrim[which] = prim;
-        data->hitTex[which] = tex;
+      if(t < data->minT[which+start]){
+        data->minT[which+start] = t;
+        data->hitMatl[which+start] = matl;
+        data->hitPrim[which+start] = prim;
+        data->hitTex[which+start] = tex;
         return true;
       } else {
         return false;
@@ -257,14 +313,14 @@
     {
       Color result;
       for(int i=0;i<Color::NumComponents;i++)
-        result[i] = data->color[i][which];
+        result[i] = data->color[i][which+start];
       return result;
     }
     Color getColor(int which) const
     {
       Color result;
       for(int i=0;i<Color::NumComponents;i++)
-        result[i] = data->color[i][which];
+        result[i] = data->color[i][which+start];
       return result;
     }
     void normalizeDirections()
@@ -400,11 +456,11 @@
     }
     bool wasHit(int which)
     {
-      return data->hitMatl[which] != 0;
+      return data->hitMatl[which+start] != 0;
     }
     const Material* hitMaterial(int which)
     {
-      return data->hitMatl[which];
+      return data->hitMatl[which+start];
     }
   private:
     RayPacket(const RayPacket&);

Modified: branches/vertical/Model/AmbientLights/ConstantAmbient.cc
==============================================================================
--- branches/vertical/Model/AmbientLights/ConstantAmbient.cc    (original)
+++ branches/vertical/Model/AmbientLights/ConstantAmbient.cc    Tue Dec 20 
17:09:36 2005
@@ -24,11 +24,10 @@
 }
 
 void ConstantAmbient::computeAmbient(const RenderContext&,
-                                    RayPacket& rays, ColorArray result) const
+                                    RayPacket& rays) const
 {
-  for(int j=0;j<Color::NumComponents;j++)
-    for(int i=0;i<rays.getSize();i++)
-      result[j][i] = color[j];
+  for(int i=0;i<rays.getSize();i++)
+    rays.setAmbientLight(i, color);
 }
 
 string ConstantAmbient::toString() const {

Modified: branches/vertical/Model/AmbientLights/ConstantAmbient.h
==============================================================================
--- branches/vertical/Model/AmbientLights/ConstantAmbient.h     (original)
+++ branches/vertical/Model/AmbientLights/ConstantAmbient.h     Tue Dec 20 
17:09:36 2005
@@ -16,7 +16,7 @@
     virtual ~ConstantAmbient();
 
     virtual void preprocess(const PreprocessContext&);
-    virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays, ColorArray result) const;
+    virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays) const;
 
     virtual std::string toString() const;
   private:

Modified: branches/vertical/Model/Lights/PointLight.cc
==============================================================================
--- branches/vertical/Model/Lights/PointLight.cc        (original)
+++ branches/vertical/Model/Lights/PointLight.cc        Tue Dec 20 17:09:36 
2005
@@ -16,17 +16,14 @@
 {
 }
 
-#if 0
 void PointLight::computeLight( Color &resultColor, Vector &lightDirection,
                                const RenderContext &/*context*/,
-                               RayPacket::Element &e ) const {
-
-       // Specify the color.
-       resultColor = color;
-       
-       // Compute the light direction.
-       lightDirection = (position - e.hitPosition);
+                               RayPacket& rays, int which ) const
+{
+  
+  // Specify the color.
+  resultColor = color;
        
+  // Compute the light direction.
+  lightDirection = (position - rays.getHitPosition(which));
 }
-
-#endif

Modified: branches/vertical/Model/Lights/PointLight.h
==============================================================================
--- branches/vertical/Model/Lights/PointLight.h (original)
+++ branches/vertical/Model/Lights/PointLight.h Tue Dec 20 17:09:36 2005
@@ -14,10 +14,9 @@
 
     virtual void preprocess(const PreprocessContext&);
     
-#if 0
     virtual void computeLight( Color &resultColor, Vector &lightDirection,
-                               const RenderContext &context, 
RayPacket::Element &e ) const;
-#endif
+                               const RenderContext &context, RayPacket & 
rays,
+                               int which ) const;
                
   private:
     Point position;

Modified: branches/vertical/Model/Materials/Phong.cc
==============================================================================
--- branches/vertical/Model/Materials/Phong.cc  (original)
+++ branches/vertical/Model/Materials/Phong.cc  Tue Dec 20 17:09:36 2005
@@ -63,36 +63,39 @@
   rays.computeNormals(context);
 
   // Compute ambient contributions for all rays
-  ColorArray ambientAndDiffuseLight;
-  activeLights->getAmbientLight()->computeAmbient(context, rays, 
ambientAndDiffuseLight);
+  activeLights->getAmbientLight()->computeAmbient(context, rays);
 
   // We normalized directions for proper dot product computation.
   rays.normalizeDirections();
 
-  ColorArray totalSpecular = Color::black();
-  ShadowData shadowState;
-  for(int light = 0; light < activeLights.size(); ){
+  int start = 0;
+
+  do {
     RayPacketData shadowData;
     RayPacket shadowRays(shadowData, 0, rays.getDepth(), 0);
 
     // Call the shadowalgorithm to generate shadow rays.  The shadowAlgorithm
     // will potentially increment the light index.  If some lights do not
     // get any shadows, it can increment by more than one at a time.
-    context.shadowAlgorithm->computeShadows(context, activeLights, light,
-                                            rays, shadowRays);
+    int end = context.shadowAlgorithm->computeShadows(context, activeLights,
+                                                      rays, start, 
shadowRays);
 
     // We normalized directions for proper dot product computation.
     shadowRays.normalizeDirections();
-    for(int i=0;i<shadowRays.size();i++){
-      if(!shadowRays.wasHit(i)){
-        // Not in shadow, so compute the direct and specular contributions.
-        ColorComponent cos_theta = Dot(shadowRays.getDirection(i), e.normal);
-        totalAmbientAndDiffuse += s.light*cos_theta;
-        Vector H = shadowRays.getDirection(i)-rays.getDirection(i???);
-        ColorComponent cos_alpha = Dot(H, rays.getNormal(???));
+    for(int i=start;i<end;i++){
+      // Initialize with the ambient contribution.
+      Color totalDiffuse(rays.getAmbientLight(i));
+      Color totalSpecular = Color::black();
+      for(int j=rays.shadowBegin(i);j<rays.shadowEnd(i);j++){
+        if(!shadowRays.wasHit(j)){
+          // Not in shadow, so compute the direct and specular contributions.
+          ColorComponent cos_theta = Dot(shadowRays.getDirection(j), 
rays.getNormal(i));
+          totalDiffuse += shadowRays.getLight(j)*cos_theta;
+          Vector H = shadowRays.getDirection(j)-rays.getDirection(i);
+          ColorComponent cos_alpha = Dot(H, rays.getNormal(i));
           if(cos_alpha > 0){
             ColorComponent length = H.length();
-            totalSpecular += s.light * ipow(cos_alpha/length, specpow);
+            totalSpecular += shadowRays.getLight(j) * ipow(cos_alpha/length, 
specpow);
           }
         }
       }
@@ -116,7 +119,7 @@
       refl_rays.setRay(i, rays.getHitPosition(i), refl_dir);
       refl_rays.setImportance(i, rays.getImportance(i) * refl[i]);
     }
-    refl_rays.resetHit();
+    refl_rays.resetHits();
     context.renderer->traceRays(context, refl_rays);
     for(int i=0;i<rays.getSize();i++)
       rays.setResult(i, rays.getColor(i) + refl_rays.getColor(i) * refl[i]);

Modified: branches/vertical/StandAlone/manta.cc
==============================================================================
--- branches/vertical/StandAlone/manta.cc       (original)
+++ branches/vertical/StandAlone/manta.cc       Tue Dec 20 17:09:36 2005
@@ -357,7 +357,6 @@
 
 Scene* createDefaultScene()
 {
-  cerr << "createDefaultScene\n";
   // Create a default scene.  This scene is used for benchmarks, so
   // please do not change it.  Please create a new scene instead
   Scene* scene = new Scene();
@@ -387,17 +386,17 @@
                           Color(RGBColor(.6,.6,.6)), 32, 
(ColorComponent)0.4);
        
   Material* plane_matl = new Phong(new 
CheckerTexture<Color>(Color(RGBColor(.6,.6,.6)),
-                                                                             
                                                                              
                                                                              
       Color(RGBColor(0,0,0)),
-                                                                             
                                                                              
                                                                              
       Vector(1,0,0),
-                                                                             
                                                                              
                                                                              
       Vector(0,1,0)),
-                                                                             
                                                           new 
Constant<Color>(Color(RGBColor(.6,.6,.6))),
-                                                                             
                                                           32,
-                                                                             
                                                           new 
CheckerTexture<ColorComponent>
+                                                             
Color(RGBColor(0,0,0)),
+                                                             Vector(1,0,0),
+                                                             Vector(0,1,0)),
+                                   new 
Constant<Color>(Color(RGBColor(.6,.6,.6))),
+                                   32,
+                                   new CheckerTexture<ColorComponent>
                                    ((ColorComponent)0.2,
                                     (ColorComponent)0.5,
                                     Vector(1,0,0),
                                     Vector(0,1,0)));
-       
+  
        
   Group* world = new Group();
   Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
@@ -417,6 +416,5 @@
   lights->setAmbientLight(new ConstantAmbient(Color::black()));
   scene->setLights(lights);
   scene->getRenderParameters().maxDepth = 5;
-  cerr << "madescene\n";
   return scene;
 }




  • [MANTA] r798 - in branches/vertical: Engine/PixelSamplers Engine/Renderers Engine/Shadows Interface Model/AmbientLights Model/Lights Model/Materials StandAlone, sparker, 12/20/2005

Archive powered by MHonArc 2.6.16.

Top of page