Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1320 - in trunk: Interface Model/Instances Model/Materials SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1320 - in trunk: Interface Model/Instances Model/Materials SwigInterface
  • Date: Sun, 1 Apr 2007 22:59:38 -0600 (MDT)

Author: bigler
Date: Sun Apr  1 22:59:36 2007
New Revision: 1320

Added:
   trunk/Model/Instances/InstanceMaterial.cc
   trunk/Model/Instances/InstanceMaterial.h
   trunk/Model/Materials/OpaqueShadower.cc
   trunk/Model/Materials/OpaqueShadower.h
Modified:
   trunk/Interface/Material.cc
   trunk/Interface/Material.h
   trunk/Model/Instances/CMakeLists.txt
   trunk/Model/Instances/Instance.cc
   trunk/Model/Instances/Instance.h
   trunk/Model/Instances/InstanceRST.cc
   trunk/Model/Instances/InstanceRST.h
   trunk/Model/Instances/InstanceRT.cc
   trunk/Model/Instances/InstanceRT.h
   trunk/Model/Instances/InstanceST.cc
   trunk/Model/Instances/InstanceST.h
   trunk/Model/Instances/InstanceT.cc
   trunk/Model/Instances/InstanceT.h
   trunk/Model/Materials/CMakeLists.txt
   trunk/Model/Materials/Checker.cc
   trunk/Model/Materials/Checker.h
   trunk/Model/Materials/CopyTextureMaterial.h
   trunk/Model/Materials/Flat.h
   trunk/Model/Materials/LitMaterial.h
   trunk/Model/Materials/NDotL.h
   trunk/Model/Materials/Null.h
   trunk/SwigInterface/manta.i
Log:

Added attenuateShadows function to the Material API.

There is now a new class caled OpaqueShadower that LitMaterial and
some other materials can inherit from.

Combined the lighting stuff for the instance code into a single class
they all inherit from.

For manta.i, I had to comment out the interface for LitMaterial.  I'll
look into this more later.


Modified: trunk/Interface/Material.cc
==============================================================================
--- trunk/Interface/Material.cc (original)
+++ trunk/Interface/Material.cc Sun Apr  1 22:59:36 2007
@@ -1,6 +1,5 @@
 
 #include <Interface/Material.h>
-#include <Core/Math/ipow.h>
 
 using namespace Manta;
 

Modified: trunk/Interface/Material.h
==============================================================================
--- trunk/Interface/Material.h  (original)
+++ trunk/Interface/Material.h  Sun Apr  1 22:59:36 2007
@@ -42,6 +42,12 @@
     
     virtual void preprocess(const PreprocessContext&) = 0;
     virtual void shade(const RenderContext& context, RayPacket& rays) const 
= 0;
+    // Multiplies the color in the ray packet (interpreted as the
+    // light color) by the material's shadow attenuation.  In the case
+    // of the material, it multiplies the light color by zero to
+    // represent no light.
+    virtual void attenuateShadows(const RenderContext& context,
+                                  RayPacket& shadowRays) const = 0;
 
   private:
     // Material(const Material&);

Modified: trunk/Model/Instances/CMakeLists.txt
==============================================================================
--- trunk/Model/Instances/CMakeLists.txt        (original)
+++ trunk/Model/Instances/CMakeLists.txt        Sun Apr  1 22:59:36 2007
@@ -1,5 +1,6 @@
 SET(Manta_Instances_SRCS
   Instances/Instance.cc
+  Instances/InstanceMaterial.cc
   Instances/InstanceRST.cc
   Instances/InstanceRT.cc
   Instances/InstanceST.cc

Modified: trunk/Model/Instances/Instance.cc
==============================================================================
--- trunk/Model/Instances/Instance.cc   (original)
+++ trunk/Model/Instances/Instance.cc   Sun Apr  1 22:59:36 2007
@@ -46,9 +46,8 @@
 Instance::Instance(Object* instance, const AffineTransform& transform)
   : instance(instance), transform(transform)
 {
-  // By default, use the texture coordinates and material of the child object
+  // By default, use the texture coordinates of the child object
   tex = this;
-  material = this;
 
   // Compute the inverse transform
   transform_inv = transform.inverse();
@@ -170,21 +169,6 @@
   tex = new_tex;
 }
 
-void Instance::shade(const RenderContext& context, RayPacket& rays) const
-{
-  for(int i=rays.begin();i<rays.end();){
-    const Material* matl = rays.scratchpad<MPT>(i).material;
-    int end = i+1;
-
-    while(end < rays.end() && rays.scratchpad<MPT>(end).material == matl)
-      end++;
-
-    RayPacket subPacket(rays, i, end);
-    matl->shade(context, subPacket);
-    i = end;
-  }
-}
-
 void Instance::computeTexCoords2(const RenderContext& context,
                               RayPacket& rays) const
 {
@@ -263,7 +247,3 @@
   rays.resetFlag(RayPacket::HaveHitPositions);
 }
 
-void Instance::overrideMaterial(Material* in_material)
-{
-  material = in_material;
-}

Modified: trunk/Model/Instances/Instance.h
==============================================================================
--- trunk/Model/Instances/Instance.h    (original)
+++ trunk/Model/Instances/Instance.h    Sun Apr  1 22:59:36 2007
@@ -29,14 +29,17 @@
 #ifndef Manta_Model_Instance_h
 #define Manta_Model_Instance_h
 
-#include <Interface/Material.h>
 #include <Interface/Primitive.h>
 #include <Interface/TexCoordMapper.h>
 #include <Core/Geometry/AffineTransform.h>
+#include <Model/Instances/InstanceMaterial.h>
 
 namespace Manta {
 
-  class Instance : public Primitive, public Material, public TexCoordMapper {
+  class Instance : public Primitive,
+                   public InstanceMaterial,
+                   public TexCoordMapper
+  {
   public:
     Instance(Object* instance, const AffineTransform& transform);
     virtual ~Instance();
@@ -51,19 +54,14 @@
     virtual void computeNormal(const RenderContext& context, RayPacket& 
rays) const;
     virtual void setTexCoordMapper(const TexCoordMapper* new_tex);
 
-    // From Material
-    virtual void shade(const RenderContext& context, RayPacket& rays) const;
-
     // From TexCoordMapper
     virtual void computeTexCoords2(const RenderContext& context,
                                   RayPacket& rays) const;
     virtual void computeTexCoords3(const RenderContext& context,
                                   RayPacket& rays) const;
 
-    void overrideMaterial(Material* material);
   private:
     Object* instance;
-    Material* material;
     const TexCoordMapper* tex;
 
         // Transformation and its inverse.

Added: trunk/Model/Instances/InstanceMaterial.cc
==============================================================================
--- (empty file)
+++ trunk/Model/Instances/InstanceMaterial.cc   Sun Apr  1 22:59:36 2007
@@ -0,0 +1,71 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Model/Instances/InstanceMaterial.h>
+#include <Model/Instances/MPT.h>
+#include <Interface/RayPacket.h>
+
+using namespace Manta;
+
+InstanceMaterial::InstanceMaterial()
+{
+  material = this;
+}
+
+void InstanceMaterial::shade(const RenderContext& context,
+                             RayPacket& rays) const
+{
+  for(int i=rays.begin();i<rays.end();){
+    const Material* matl = rays.scratchpad<MPT>(i).material;
+    int end = i+1;
+    while(end < rays.end() && rays.scratchpad<MPT>(end).material == matl)
+      end++;
+    RayPacket subPacket(rays, i, end);
+    matl->shade(context, subPacket);
+    i = end;
+  }
+}
+
+void InstanceMaterial::attenuateShadows(const RenderContext& context,
+                                        RayPacket& shadowRays) const
+{
+  for(int i=shadowRays.begin();i<shadowRays.end();){
+    const Material* matl = shadowRays.scratchpad<MPT>(i).material;
+    int end = i+1;
+    while(end < shadowRays.end() && shadowRays.scratchpad<MPT>(end).material 
== matl)
+      end++;
+    RayPacket subPacket(shadowRays, i, end);
+    matl->attenuateShadows(context, subPacket);
+    i = end;
+  }
+}
+
+void InstanceMaterial::overrideMaterial(Material* in_material)
+{
+  material = in_material;
+}

Added: trunk/Model/Instances/InstanceMaterial.h
==============================================================================
--- (empty file)
+++ trunk/Model/Instances/InstanceMaterial.h    Sun Apr  1 22:59:36 2007
@@ -0,0 +1,58 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef Manta_Model_InstanceMaterial_h
+#define Manta_Model_InstanceMaterial_h
+
+/*
+  This constains code that implements the Material interface and is
+  common to all the instances.
+  
+ */
+
+#include <Interface/Material.h>
+
+namespace Manta {
+
+  class InstanceMaterial : public Material {
+  public:
+    InstanceMaterial();
+    virtual ~InstanceMaterial() {}
+
+    virtual void shade(const RenderContext& context, RayPacket& rays) const;
+    virtual void attenuateShadows(const RenderContext& context,
+                                  RayPacket& shadowRays) const;
+
+    void overrideMaterial(Material* material);
+  protected:
+    Material* material;
+    
+  };
+} // end namespace Manta
+
+#endif // #ifndef Manta_Model_InstanceMaterial_h

Modified: trunk/Model/Instances/InstanceRST.cc
==============================================================================
--- trunk/Model/Instances/InstanceRST.cc        (original)
+++ trunk/Model/Instances/InstanceRST.cc        Sun Apr  1 22:59:36 2007
@@ -43,9 +43,8 @@
 InstanceRST::InstanceRST(Object* instance, const AffineTransform& transform_ 
)
   : instance(instance), transform(transform_), 
transform_inv(transform_.inverse())
 {
-  // By default, use the texture coordinates and material of the child object
+  // By default, use the texture coordinates of the child object
   tex = this;
-  material = this;
 
   // Determine the scale of the matrix.  We could use eigenvalue analysis,
   // but this seems easier:  pass in the three axes and make sure that the
@@ -176,21 +175,6 @@
   tex = new_tex;
 }
 
-void InstanceRST::shade(const RenderContext& context, RayPacket& rays) const
-{
-  for(int i=rays.begin();i<rays.end();){
-    const Material* matl = rays.scratchpad<MPT>(i).material;
-    int end = i+1;
-
-    while(end < rays.end() && rays.scratchpad<MPT>(end).material == matl)
-      end++;
-
-    RayPacket subPacket(rays, i, end);
-    matl->shade(context, subPacket);
-    i = end;
-  }
-}
-
 void InstanceRST::computeTexCoords2(const RenderContext& context,
                               RayPacket& rays) const
 {
@@ -265,7 +249,3 @@
   rays.resetFlag(RayPacket::HaveHitPositions);
 }
 
-void InstanceRST::overrideMaterial(Material* in_material)
-{
-  material = in_material;
-}

Modified: trunk/Model/Instances/InstanceRST.h
==============================================================================
--- trunk/Model/Instances/InstanceRST.h (original)
+++ trunk/Model/Instances/InstanceRST.h Sun Apr  1 22:59:36 2007
@@ -29,14 +29,17 @@
 #ifndef Manta_Model_InstanceRST_h
 #define Manta_Model_InstanceRST_h
 
-#include <Interface/Material.h>
 #include <Interface/Primitive.h>
 #include <Interface/TexCoordMapper.h>
 #include <Core/Geometry/AffineTransform.h>
+#include <Model/Instances/InstanceMaterial.h>
 
 namespace Manta {
 
-  class InstanceRST : public Primitive, public Material, public 
TexCoordMapper {
+  class InstanceRST : public Primitive,
+                      public InstanceMaterial,
+                      public TexCoordMapper
+  {
   public:
 
     InstanceRST(Object* instance, const AffineTransform& transform_);
@@ -51,20 +54,13 @@
     virtual void computeNormal    (const RenderContext& context, RayPacket& 
rays) const;
     virtual void setTexCoordMapper(const TexCoordMapper* new_tex);
 
-    // From Material
-    virtual void shade(const RenderContext& context, RayPacket& rays) const;
-
     // From TexCoordMapper
     virtual void computeTexCoords2(const RenderContext& context, RayPacket& 
rays) const;
     virtual void computeTexCoords3(const RenderContext& context, RayPacket& 
rays) const;
-
-    void overrideMaterial(Material* material);
-        
   private:
         
         // Instanced Object & Properties.
     Object* instance;
-    Material* material;
     const TexCoordMapper* tex;
 
         // Transform and its inverse.

Modified: trunk/Model/Instances/InstanceRT.cc
==============================================================================
--- trunk/Model/Instances/InstanceRT.cc (original)
+++ trunk/Model/Instances/InstanceRT.cc Sun Apr  1 22:59:36 2007
@@ -43,9 +43,8 @@
 InstanceRT::InstanceRT(Object* instance, const AffineTransform& transform_ )
   : instance(instance), transform( transform_ ), transform_inv( 
transform_.inverse() )
 {
-  // By default, use the texture coordinates and material of the child object
+  // By default, use the texture coordinates of the child object
   tex = this;
-  material = this;
 
   // Determine the scale of the matrix.  We could use eigenvalue analysis,
   // but this seems easier:  pass in the three axes and make sure that the
@@ -174,20 +173,6 @@
   tex = new_tex;
 }
 
-void InstanceRT::shade(const RenderContext& context, RayPacket& rays) const
-{
-  for(int i=rays.begin();i<rays.end();){
-    const Material* matl = rays.scratchpad<MPT>(i).material;
-    int end = i+1;
-    while(end < rays.end() && rays.scratchpad<MPT>(end).material == matl)
-      end++;
-    RayPacket subPacket(rays, i, end);
-    matl->shade(context, subPacket);
-    i = end;
-  }
-}
-
-
 void InstanceRT::computeTexCoords2(const RenderContext& context,
                               RayPacket& rays) const
 {
@@ -254,7 +239,3 @@
   rays.resetFlag(RayPacket::HaveHitPositions);
 }
 
-void InstanceRT::overrideMaterial(Material* in_material)
-{
-  material = in_material;
-}

Modified: trunk/Model/Instances/InstanceRT.h
==============================================================================
--- trunk/Model/Instances/InstanceRT.h  (original)
+++ trunk/Model/Instances/InstanceRT.h  Sun Apr  1 22:59:36 2007
@@ -29,14 +29,17 @@
 #ifndef Manta_Model_InstanceRT_h
 #define Manta_Model_InstanceRT_h
 
-#include <Interface/Material.h>
 #include <Interface/Primitive.h>
 #include <Interface/TexCoordMapper.h>
 #include <Core/Geometry/AffineTransform.h>
+#include <Model/Instances/InstanceMaterial.h>
 
 namespace Manta {
 
-  class InstanceRT : public Primitive, public Material, public 
TexCoordMapper {
+  class InstanceRT : public Primitive,
+                     public InstanceMaterial,
+                     public TexCoordMapper
+  {
   public:
     InstanceRT(Object* instance, const AffineTransform& transform_);
     virtual ~InstanceRT();
@@ -51,21 +54,14 @@
     virtual void computeNormal(const RenderContext& context, RayPacket& 
rays) const;
     virtual void setTexCoordMapper(const TexCoordMapper* new_tex);
 
-    // From Material
-    virtual void shade(const RenderContext& context, RayPacket& rays) const;
-
     // From TexCoordMapper
     virtual void computeTexCoords2(const RenderContext& context,
                                   RayPacket& rays) const;
     virtual void computeTexCoords3(const RenderContext& context,
                                   RayPacket& rays) const;
 
-    void overrideMaterial(Material* material);
-
-
   private:
     Object* instance;
-    Material* material;
     const TexCoordMapper* tex;
         
         AffineTransform transform;

Modified: trunk/Model/Instances/InstanceST.cc
==============================================================================
--- trunk/Model/Instances/InstanceST.cc (original)
+++ trunk/Model/Instances/InstanceST.cc Sun Apr  1 22:59:36 2007
@@ -37,9 +37,8 @@
                        const Vector& translation)
   : instance(instance), scale(scale), translation(translation)
 {
-  // By default, use the texture coordinates and material of the child object
+  // By default, use the texture coordinates of the child object
   tex = this;
-  material = this;
   if(scale.x() == scale.y() && scale.y() == scale.z())
     uniform_scale = true;
   else
@@ -213,19 +212,6 @@
   tex = new_tex;
 }
 
-void InstanceST::shade(const RenderContext& context, RayPacket& rays) const
-{
-  for(int i=rays.begin();i<rays.end();){
-    const Material* matl = rays.scratchpad<MPT>(i).material;
-    int end = i+1;
-    while(end < rays.end() && rays.scratchpad<MPT>(end).material == matl)
-      end++;
-    RayPacket subPacket(rays, i, end);
-    matl->shade(context, subPacket);
-    i = end;
-  }
-}
-
 void InstanceST::computeTexCoords2(const RenderContext& context,
                                    RayPacket& rays) const
 {
@@ -340,8 +326,3 @@
   rays.resetFlag(RayPacket::HaveHitPositions);
 }
 
-
-void InstanceST::overrideMaterial(Material* in_material)
-{
-  material = in_material;
-}

Modified: trunk/Model/Instances/InstanceST.h
==============================================================================
--- trunk/Model/Instances/InstanceST.h  (original)
+++ trunk/Model/Instances/InstanceST.h  Sun Apr  1 22:59:36 2007
@@ -29,14 +29,17 @@
 #ifndef Manta_Model_InstanceST_h
 #define Manta_Model_InstanceST_h
 
-#include <Interface/Material.h>
 #include <Interface/Primitive.h>
 #include <Interface/TexCoordMapper.h>
 #include <Core/Geometry/Vector.h>
+#include <Model/Instances/InstanceMaterial.h>
 
 namespace Manta {
 
-  class InstanceST : public Primitive, public Material, public 
TexCoordMapper {
+  class InstanceST : public Primitive,
+                     public InstanceMaterial,
+                     public TexCoordMapper
+  {
   public:
     InstanceST(Object* instance, const Vector& scale,
                const Vector& translation);
@@ -52,22 +55,16 @@
     virtual void computeNormal(const RenderContext& context, RayPacket& 
rays) const;
     virtual void setTexCoordMapper(const TexCoordMapper* new_tex);
 
-    // From Material
-    virtual void shade(const RenderContext& context, RayPacket& rays) const;
-
     // From TexCoordMapper
     virtual void computeTexCoords2(const RenderContext& context,
                                   RayPacket& rays) const;
     virtual void computeTexCoords3(const RenderContext& context,
                                   RayPacket& rays) const;
-
-    void overrideMaterial(Material* material);
   private:
 
     Object* instance;
     Vector scale;
     Vector translation;
-    Material* material;
     const TexCoordMapper* tex;
     Vector inv_scale;
     bool uniform_scale;

Modified: trunk/Model/Instances/InstanceT.cc
==============================================================================
--- trunk/Model/Instances/InstanceT.cc  (original)
+++ trunk/Model/Instances/InstanceT.cc  Sun Apr  1 22:59:36 2007
@@ -36,9 +36,8 @@
 InstanceT::InstanceT(Object* instance, const Vector& translation)
   : instance(instance), translation(translation)
 {
-  // By default, use the texture coordinates and material of the child object
+  // By default, use the texture coordinates of the child object
   tex = this;
-  material = this;
 }
 
 InstanceT::~InstanceT()
@@ -130,20 +129,6 @@
   tex = new_tex;
 }
 
-void InstanceT::shade(const RenderContext& context, RayPacket& rays) const
-{
-  for(int i=rays.begin();i<rays.end();){
-    const Material* matl = rays.scratchpad<MPT>(i).material;
-    int end = i+1;
-    while(end < rays.end() && rays.scratchpad<MPT>(end).material == matl)
-      end++;
-    RayPacket subPacket(rays, i, end);
-    matl->shade(context, subPacket);
-    i = end;
-  }
-}
-
-
 void InstanceT::computeTexCoords2(const RenderContext& context,
                                   RayPacket& rays) const
 {
@@ -198,9 +183,4 @@
   for(int i=rays.begin();i<rays.end();i++){
     rays.setOrigin(i, old_origins[i]);
   }
-}
-
-void InstanceT::overrideMaterial(Material* in_material)
-{
-  material = in_material;
 }

Modified: trunk/Model/Instances/InstanceT.h
==============================================================================
--- trunk/Model/Instances/InstanceT.h   (original)
+++ trunk/Model/Instances/InstanceT.h   Sun Apr  1 22:59:36 2007
@@ -29,14 +29,17 @@
 #ifndef Manta_Model_InstanceT_h
 #define Manta_Model_InstanceT_h
 
-#include <Interface/Material.h>
 #include <Interface/Primitive.h>
 #include <Interface/TexCoordMapper.h>
 #include <Core/Geometry/Vector.h>
+#include <Model/Instances/InstanceMaterial.h>
 
 namespace Manta {
 
-  class InstanceT : public Primitive, public Material, public TexCoordMapper 
{
+  class InstanceT : public Primitive,
+                    public InstanceMaterial,
+                    public TexCoordMapper
+  {
   public:
     InstanceT(Object* instance, const Vector& translation);
     virtual ~InstanceT();
@@ -51,20 +54,14 @@
     virtual void computeNormal(const RenderContext& context, RayPacket& 
rays) const;
     virtual void setTexCoordMapper(const TexCoordMapper* new_tex);
 
-    // From Material
-    virtual void shade(const RenderContext& context, RayPacket& rays) const;
-
     // From TexCoordMapper
     virtual void computeTexCoords2(const RenderContext& context,
                                   RayPacket& rays) const;
     virtual void computeTexCoords3(const RenderContext& context,
                                   RayPacket& rays) const;
-
-    void overrideMaterial(Material* material);
   private:
     Object* instance;
     Vector translation;
-    Material* material;
     const TexCoordMapper* tex;
   };
 }

Modified: trunk/Model/Materials/CMakeLists.txt
==============================================================================
--- trunk/Model/Materials/CMakeLists.txt        (original)
+++ trunk/Model/Materials/CMakeLists.txt        Sun Apr  1 22:59:36 2007
@@ -20,6 +20,8 @@
      Materials/MetalMaterial.cc
      Materials/NDotL.h
      Materials/NDotL.cc
+     Materials/OpaqueShadower.h
+     Materials/OpaqueShadower.cc
      Materials/Phong.h
      Materials/Phong.cc
      Materials/Transparent.cc

Modified: trunk/Model/Materials/Checker.cc
==============================================================================
--- trunk/Model/Materials/Checker.cc    (original)
+++ trunk/Model/Materials/Checker.cc    Sun Apr  1 22:59:36 2007
@@ -5,7 +5,7 @@
 using namespace Manta;
 
 Checker::Checker(Material* m1, Material* m2, const Vector& v1,
-                const Vector& v2)
+                 const Vector& v2)
   : m1(m1), m2(m2), v1(v1), v2(v2)
 {
   if(v1.z() == 0 && v2.z() == 0)
@@ -56,7 +56,7 @@
       int i2 = (int)vv2;
       which = (i1+i2)%2;
       if(which != which0)
-       break;
+        break;
       stop++;
     }
     RayPacket subrays(rays, start, stop);
@@ -65,3 +65,50 @@
     start = stop;
   }
 }
+
+// TODO(bigler): the only difference between shade and
+// attenuateShadows is the single function call to the children.
+// There must be a way to pass in a function pointer or something.
+void Checker::attenuateShadows(const RenderContext& context,
+                               RayPacket& shadowRays) const
+{
+  if(need_w)
+    shadowRays.computeTextureCoordinates3(context);
+  else
+    shadowRays.computeTextureCoordinates2(context);
+  Real vv1 = Dot(shadowRays.getTexCoords(0), v1);
+  Real vv2 = Dot(shadowRays.getTexCoords(0), v2);
+  if(vv1<0)
+    vv1=-vv1+1;
+  if(vv2<0)
+    vv2=-vv2+1;
+  int i1 = (int)vv1;
+  int i2 = (int)vv2;
+  int which0 = (i1+i2)%2;
+  for(int start = shadowRays.begin(); start < shadowRays.end();){
+    int stop = start+1;
+    // I'm not sure what the default value for "which" should be, but
+    // this will not change the value of "which0" if "which" is never
+    // changed.  - James Bigler
+    int which = which0;
+    while(stop < shadowRays.end()){
+      Real vv1 = Dot(shadowRays.getTexCoords(stop), v1);
+      Real vv2 = Dot(shadowRays.getTexCoords(stop), v2);
+      if(vv1<0)
+        vv1=-vv1+1;
+      if(vv2<0)
+        vv2=-vv2+1;
+      int i1 = (int)vv1;
+      int i2 = (int)vv2;
+      which = (i1+i2)%2;
+      if(which != which0)
+        break;
+      stop++;
+    }
+    RayPacket subshadowRays(shadowRays, start, stop);
+    (which0?m2:m1)->attenuateShadows(context, subshadowRays);
+    which0 = which;
+    start = stop;
+  }
+}
+

Modified: trunk/Model/Materials/Checker.h
==============================================================================
--- trunk/Model/Materials/Checker.h     (original)
+++ trunk/Model/Materials/Checker.h     Sun Apr  1 22:59:36 2007
@@ -15,6 +15,8 @@
 
     virtual void preprocess(const PreprocessContext&);
     virtual void shade(const RenderContext& context, RayPacket& rays) const;
+    virtual void attenuateShadows(const RenderContext& context,
+                                  RayPacket& shadowRays) const;
   private:
     Material* m1;
     Material* m2;

Modified: trunk/Model/Materials/CopyTextureMaterial.h
==============================================================================
--- trunk/Model/Materials/CopyTextureMaterial.h (original)
+++ trunk/Model/Materials/CopyTextureMaterial.h Sun Apr  1 22:59:36 2007
@@ -32,7 +32,7 @@
 #include <Core/Color/Color.h>
 
 #include <Interface/Texture.h>
-#include <Interface/Material.h>
+#include <Model/Materials/OpaqueShadower.h>
 
 namespace Manta {
 
@@ -40,7 +40,7 @@
     This material simply uses the values of the texture as the final
     result disregarding any lighing parameters.
   */
-  class CopyTextureMaterial: public Material {
+  class CopyTextureMaterial: public OpaqueShadower {
   public:
     CopyTextureMaterial(const Color& color);
     CopyTextureMaterial(const Texture<Color>* colortex);

Modified: trunk/Model/Materials/Flat.h
==============================================================================
--- trunk/Model/Materials/Flat.h        (original)
+++ trunk/Model/Materials/Flat.h        Sun Apr  1 22:59:36 2007
@@ -32,13 +32,13 @@
 
 #include <Core/Color/Color.h>
 
-#include <Interface/Material.h>
+#include <Model/Materials/OpaqueShadower.h>
 #include <Interface/Texture.h>
 
 
 
 namespace Manta {
-  class Flat : public Material {
+  class Flat : public OpaqueShadower {
   public:
     Flat(const Color& color);
     Flat(const Texture<Color>* colortex);
@@ -46,7 +46,6 @@
 
     virtual void preprocess(const PreprocessContext&);
     virtual void shade(const RenderContext& context, RayPacket& rays) const;
-
   private:
     Texture<Color> const *colortex;
   };

Modified: trunk/Model/Materials/LitMaterial.h
==============================================================================
--- trunk/Model/Materials/LitMaterial.h (original)
+++ trunk/Model/Materials/LitMaterial.h Sun Apr  1 22:59:36 2007
@@ -2,17 +2,18 @@
 #ifndef Manta_Model_LitMaterial_h
 #define Manta_Model_LitMaterial_h
 
-#include <Interface/Material.h>
+#include <Model/Materials/OpaqueShadower.h>
 
 namespace Manta {
   class LightSet;
 
-  class LitMaterial : public Material {
+  class LitMaterial : public OpaqueShadower {
   public:
     LitMaterial();
     virtual ~LitMaterial();
 
     virtual void preprocess(const PreprocessContext&);
+
   protected:
     const LightSet* activeLights;
     LightSet* localLights;

Modified: trunk/Model/Materials/NDotL.h
==============================================================================
--- trunk/Model/Materials/NDotL.h       (original)
+++ trunk/Model/Materials/NDotL.h       Sun Apr  1 22:59:36 2007
@@ -32,12 +32,12 @@
 
 #include <Core/Color/Color.h>
 #include <Core/Geometry/Vector.h>
-#include <Interface/Material.h>
+#include <Model/Materials/OpaqueShadower.h>
 #include <Interface/Texture.h>
 
 namespace Manta
 {
-  class NDotL : public Material
+  class NDotL : public OpaqueShadower
   {
   public:
       NDotL(const Vector& d, const Color& color);

Modified: trunk/Model/Materials/Null.h
==============================================================================
--- trunk/Model/Materials/Null.h        (original)
+++ trunk/Model/Materials/Null.h        Sun Apr  1 22:59:36 2007
@@ -43,6 +43,8 @@
 
     virtual void preprocess(const PreprocessContext&) { }
     virtual void shade(const RenderContext& context, RayPacket& rays) const 
{ }
+    virtual void attenuateShadows(const RenderContext& context,
+                                  RayPacket& shadowRays) const { };
 
   private:
   };

Added: trunk/Model/Materials/OpaqueShadower.cc
==============================================================================
--- (empty file)
+++ trunk/Model/Materials/OpaqueShadower.cc     Sun Apr  1 22:59:36 2007
@@ -0,0 +1,68 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Model/Materials/OpaqueShadower.h>
+
+#include <MantaSSE.h>
+#include <Interface/RayPacket.h>
+#include <Interface/Context.h>
+#include <Core/Color/Color.h>
+
+using namespace Manta;
+
+void OpaqueShadower::attenuateShadows(const RenderContext& context,
+                                      RayPacket& shadowRays) const
+{
+#ifdef MANTA_SSE
+  int b = (shadowRays.rayBegin + 3) & (~3);
+  int e = shadowRays.rayEnd & (~3);
+  if(b == e){
+    for(int i = shadowRays.begin(); i < shadowRays.end(); i++){
+      shadowRays.setColor(i, Color::black());
+    }
+  } else {
+    int i = shadowRays.rayBegin;
+    for(;i<b;i++){
+      shadowRays.setColor(i, Color::black());
+    }
+    RayPacketData* shadowData = shadowRays.data;
+    for(;i<e;i+=4){
+      _mm_store_ps(&shadowData->color[0][i], _mm_zero);
+      _mm_store_ps(&shadowData->color[1][i], _mm_zero);
+      _mm_store_ps(&shadowData->color[2][i], _mm_zero);
+    }
+    for(;i<shadowRays.rayEnd;i++){
+      shadowRays.setColor(i, Color::black());
+    }
+  }
+#else
+  for(int i = shadowRays.begin(); i < shadowRays.end(); i++){
+    shadowRays.setColor(i, Color::black());
+  }
+#endif
+}

Added: trunk/Model/Materials/OpaqueShadower.h
==============================================================================
--- (empty file)
+++ trunk/Model/Materials/OpaqueShadower.h      Sun Apr  1 22:59:36 2007
@@ -0,0 +1,51 @@
+#ifndef MODEL_MATERIALS_OPAQUESHADOWER_H__
+#define MODEL_MATERIALS_OPAQUESHADOWER_H__
+
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Interface/Material.h>
+
+namespace Manta {
+  
+  class OpaqueShadower: public Material {
+  public:
+    OpaqueShadower() {} 
+    virtual ~OpaqueShadower() {}
+    
+    // Multiplies the color in the ray packet (interpreted as the
+    // light color) by the material's shadow attenuation.  In the case
+    // of the material, it multiplies the light color by zero to
+    // represent no light.
+    virtual void attenuateShadows(const RenderContext& context,
+                                  RayPacket& shadowRays) const;
+
+  };
+} // end namespace Manta
+
+#endif // #ifndef MODEL_MATERIALS_OPAQUESHADOWER_H__

Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Sun Apr  1 22:59:36 2007
@@ -168,7 +168,7 @@
 /////////////////////////////////////////////////////
 // Materials and Primitivs
 %{
-#include <Model/Materials/LitMaterial.h>
+//#include <Model/Materials/LitMaterial.h>
 #include <Model/Materials/Phong.h>
 #include <Model/Materials/Lambertian.h>
 #include <Model/Materials/MetalMaterial.h>
@@ -186,7 +186,7 @@
 #include <Model/Groups/RealisticBvh.h>
 %}
 
-%include <Model/Materials/LitMaterial.h>
+//%include <Model/Materials/LitMaterial.h>
 %include <Model/Materials/Phong.h>
 %include <Model/Materials/Lambertian.h>
 %include <Model/Materials/MetalMaterial.h>




  • [MANTA] r1320 - in trunk: Interface Model/Instances Model/Materials SwigInterface, bigler, 04/01/2007

Archive powered by MHonArc 2.6.16.

Top of page