Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2025 - in trunk/Model: Instances Primitives


Chronological Thread 
  • From: "Austin Robison" <arobison@rayscale.com>
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2025 - in trunk/Model: Instances Primitives
  • Date: Thu, 31 Jan 2008 15:47:07 -0700 (MST)

Author: arobison
Date: Thu Jan 31 15:47:05 2008
New Revision: 2025

Modified:
   trunk/Model/Instances/Instance.cc
   trunk/Model/Instances/Instance.h
   trunk/Model/Instances/MPT.h
   trunk/Model/Primitives/MeshTriangle.cc
Log:
Forwarding surface derivative information through instances and
fixing a typo in MeshTriangle's computeSurfaceDerivatives 
implementation.



Modified: trunk/Model/Instances/Instance.cc
==============================================================================
--- trunk/Model/Instances/Instance.cc   (original)
+++ trunk/Model/Instances/Instance.cc   Thu Jan 31 15:47:05 2008
@@ -361,6 +361,7 @@
       // NOTE(boulos): Once the texcoords are separated, there will be
       // another call to texcoords 3 here
       sub_packet.computeTextureCoordinates2(context);
+      sub_packet.computeSurfaceDerivatives(context);
 
       // TODO(bigler: change this to zero when we fix InstanceMaterial)
       bool override_material = material != this;
@@ -377,7 +378,9 @@
           // requested
           rays.scratchpad<InstanceShadingData>(j) =
             InstanceShadingData(sub_packet.getNormal(j),
-                                sub_packet.getTexCoords2(j));
+                                sub_packet.getTexCoords2(j),
+                                sub_packet.getSurfaceDerivativeU(j),
+                                sub_packet.getSurfaceDerivativeV(j));
         }
       }
       i = end;
@@ -418,3 +421,12 @@
   rays.setFlag(RayPacket::HaveTexture3);
 }
 
+void Instance::computeSurfaceDerivatives(const RenderContext& context,
+                                         RayPacket& rays) const
+{
+  for (int i = rays.begin(); i < rays.end(); i++) {
+    rays.setSurfaceDerivativeU(i, 
rays.scratchpad<InstanceShadingData>(i).surfDerivU);
+    rays.setSurfaceDerivativeV(i, 
rays.scratchpad<InstanceShadingData>(i).surfDerivV);
+  }
+  rays.setFlag(RayPacket::HaveSurfaceDerivatives);
+}

Modified: trunk/Model/Instances/Instance.h
==============================================================================
--- trunk/Model/Instances/Instance.h    (original)
+++ trunk/Model/Instances/Instance.h    Thu Jan 31 15:47:05 2008
@@ -67,6 +67,8 @@
                                    RayPacket& rays) const;
     virtual void computeTexCoords3(const RenderContext& context,
                                    RayPacket& rays) const;
+    virtual void computeSurfaceDerivatives(const RenderContext& context,
+                                           RayPacket& rays) const;
 
     virtual void addToUpdateGraph(ObjectUpdateGraph* graph,
                                   ObjectUpdateGraphNode* parent);

Modified: trunk/Model/Instances/MPT.h
==============================================================================
--- trunk/Model/Instances/MPT.h (original)
+++ trunk/Model/Instances/MPT.h Thu Jan 31 15:47:05 2008
@@ -52,10 +52,17 @@
     // separated add this one too.
     //
     //Vector texcoord3;
+    Vector surfDerivU;
+    Vector surfDerivV;
 
     InstanceShadingData(const Vector& normal,
-                        const VectorT<Real, 2>& tex2)
-      : normal(normal), texcoord2(tex2) {
+                        const VectorT<Real, 2>& tex2,
+                        const Vector& dpdu,
+                        const Vector& dpdv
+                        )
+      : normal(normal), texcoord2(tex2), 
+        surfDerivU(dpdu), surfDerivV(dpdv)  
+    {
     }
   };
 }

Modified: trunk/Model/Primitives/MeshTriangle.cc
==============================================================================
--- trunk/Model/Primitives/MeshTriangle.cc      (original)
+++ trunk/Model/Primitives/MeshTriangle.cc      Thu Jan 31 15:47:05 2008
@@ -33,7 +33,7 @@
 
   // compute dPdu and dPdv based on face normals
   const Vector uv_diff0 = uv1 - uv0;
-  const Vector uv_diff1 = uv2 - uv1;
+  const Vector uv_diff1 = uv2 - uv0;
 
   const Vector edge0 = vec1 - vec0;
   const Vector edge1 = vec2 - vec0;




  • [Manta] r2025 - in trunk/Model: Instances Primitives, Austin Robison, 01/31/2008

Archive powered by MHonArc 2.6.16.

Top of page