Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1412 - in trunk: Engine/Shadows Interface Model/Lights


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1412 - in trunk: Engine/Shadows Interface Model/Lights
  • Date: Sat, 9 Jun 2007 23:55:27 -0600 (MDT)

Author: bigler
Date: Sat Jun  9 23:55:26 2007
New Revision: 1412

Modified:
   trunk/Engine/Shadows/HardShadows.cc
   trunk/Interface/Light.h
   trunk/Model/Lights/HeadLight.cc
   trunk/Model/Lights/PointLight.cc
Log:

Engine/Shadows/HardShadows.cc

  Turned off SSE until I figure out why the non SSE code is weird.
  Now, don't normalize the light directory and set minT to the
  length.  Instead the minT should have been set by the light.

Interface/Light.h

  Some comments on what the computeLight function should do.

Model/Lights/HeadLight.cc
Model/Lights/PointLight.cc

  Set the minT value to comply with new API for lights.


Modified: trunk/Engine/Shadows/HardShadows.cc
==============================================================================
--- trunk/Engine/Shadows/HardShadows.cc (original)
+++ trunk/Engine/Shadows/HardShadows.cc Sat Jun  9 23:55:26 2007
@@ -19,6 +19,10 @@
 using namespace Manta;
 using std::cerr;
 
+#ifdef MANTA_SSE
+#undef MANTA_SSE
+#endif
+
 ShadowAlgorithm* HardShadows::create(const vector<string>& args)
 {
   return new HardShadows(args);
@@ -84,12 +88,12 @@
       for(int i = sourceRays.begin(); i < sourceRays.end(); i++){
         Vector dir = shadowRays.getDirection(i);
         if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
-          // If so normalize and compute length.
-          Real length = dir.normalize();
-
-          // Populate the shadow ray.
-          shadowRays.setRay(i, sourceRays.getHitPosition(i), dir );
-          shadowRays.resetHit(i, length );
+          shadowRays.setOrigin(sourceRays.getHitPosition(i));
+          // This is a version of resetHit that only sets the material
+          // to NULL and doesn't require us to also modify the hit
+          // distance which was set for us by the call to
+          // computeLight.
+          shadowRays.setHitMaterial(i, NULL);
           last = i;
           if (first < 0)
             first = i;
@@ -102,13 +106,9 @@
       for(;i<b;i++){
         Vector dir = shadowRays.getDirection(i);
         if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
-
-          // If so normalize and compute length.
-          Real length = dir.normalize();
-
-          // Populate the shadow ray.
-          shadowRays.setRay(i, sourceRays.getHitPosition(i), dir );
-          shadowRays.resetHit(i, length );
+          shadowRays.setOrigin(sourceRays.getHitPosition(i));
+          // See comment above.
+          shadowRays.setHitMaterial(i, NULL);
           last = i;
           if (first < 0)
             first = i;
@@ -167,13 +167,9 @@
       for(;i<sourceRays.rayEnd;i++){
         Vector dir = shadowRays.getDirection(i);
         if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
-
-          // If so normalize and compute length.
-          Real length = dir.normalize();
-
-          // Populate the shadow ray.
-          shadowRays.setRay(i, sourceRays.getHitPosition(i), dir );
-          shadowRays.resetHit(i, length );
+          shadowRays.setOrigin(sourceRays.getHitPosition(i));
+          // See comment above.
+          shadowRays.setHitMaterial(i, NULL);
           last = i;
           if (first < 0)
             first = i;
@@ -187,13 +183,13 @@
       // Check to see if the light is on the front face.
       Vector dir = shadowRays.getDirection(i);
       if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
-
-        // If so normalize and compute length.
-        Real length = dir.normalize();
-
-        // Populate the shadow ray.
-        shadowRays.setRay(i, sourceRays.getHitPosition(i), dir );
-        shadowRays.resetHit(i, length );
+        shadowRays.setOrigin(i, sourceRays.getHitPosition(i));
+#if 1
+        shadowRays.resetHit(i, sourceRays.getMinT(i));
+#else
+        // See comment above.
+        shadowRays.setHitMaterial(i, NULL);
+#endif
         last = i;
         if (first < 0)
           first = i;
@@ -207,9 +203,7 @@
 
   // Send the shadow rays, if any
   if(last != -1){
-    shadowRays.setFlag( RayPacket::NormalizedDirections );
     shadowRays.resize ( first, last + 1);
-    //shadowRays.resetHits();
     context.scene->getObject()->intersect(context, shadowRays);
     if (attenuateShadows) {
       bool raysActive;
@@ -253,7 +247,6 @@
           // new shadow ray and keep it going.
           for(int i = shadowRays.begin();i<shadowRays.end();){
             int end = i+1;
-            const Material* hit_matl = shadowRays.getHitMaterial(i);
             if(rayAttenudated[i]) {
               if (shadowRays.getColor(i).luminance() > cutoff) {
                 if (!raysActive) {

Modified: trunk/Interface/Light.h
==============================================================================
--- trunk/Interface/Light.h     (original)
+++ trunk/Interface/Light.h     Sat Jun  9 23:55:26 2007
@@ -21,6 +21,12 @@
     // 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.
+    //
+    // This function is in charge of filling in:
+    // 1. The color:     RayPacket::setColor()
+    // 2. The direction: RayPacket::setDirection()
+    // 3. The distance:  RayPacket::overrideMinT() (in terms of the
+    //                                              direction length).
     virtual void computeLight(RayPacket& destRays,
                               const RenderContext &context,
                               RayPacket& sourceRays) const = 0;

Modified: trunk/Model/Lights/HeadLight.cc
==============================================================================
--- trunk/Model/Lights/HeadLight.cc     (original)
+++ trunk/Model/Lights/HeadLight.cc     Sat Jun  9 23:55:26 2007
@@ -23,5 +23,6 @@
   for(int i = sourceRays.begin(); i < sourceRays.end(); i++){
     destRays.setColor(i, color);
     destRays.setDirection(i, position - sourceRays.getHitPosition(i));
+    destRays.overrideMinT(i, 1);
   }
 }

Modified: trunk/Model/Lights/PointLight.cc
==============================================================================
--- trunk/Model/Lights/PointLight.cc    (original)
+++ trunk/Model/Lights/PointLight.cc    Sat Jun  9 23:55:26 2007
@@ -28,12 +28,14 @@
       for(int i = sourceRays.begin(); i < sourceRays.end(); i++){
         destRays.setColor(i, color);
         destRays.setDirection(i, position - sourceRays.getHitPosition(i));
+        destRays.overrideMinT(i, 1);
       }
     } else {
       int i = sourceRays.rayBegin;
       for(;i<b;i++){
         destRays.setColor(i, color);
         destRays.setDirection(i, position - sourceRays.getHitPosition(i));
+        destRays.overrideMinT(i, 1);
       }
       RayPacketData* sourceData = sourceRays.data;
       RayPacketData* destData = destRays.data;
@@ -44,16 +46,19 @@
         _mm_store_ps(&destData->direction[0][i], 
_mm_sub_ps(_mm_set1_ps(position[0]), 
_mm_load_ps(&sourceData->hitPosition[0][i])));
         _mm_store_ps(&destData->direction[1][i], 
_mm_sub_ps(_mm_set1_ps(position[1]), 
_mm_load_ps(&sourceData->hitPosition[1][i])));
         _mm_store_ps(&destData->direction[2][i], 
_mm_sub_ps(_mm_set1_ps(position[2]), 
_mm_load_ps(&sourceData->hitPosition[2][i])));
+        _mm_store_ps(&destData->minT[i], _mm_set1_ps(1));
       }
       for(;i<sourceRays.rayEnd;i++){
         destRays.setColor(i, color);
         destRays.setDirection(i, position - sourceRays.getHitPosition(i));
+        destRays.overrideMinT(i, 1);
       }
     }
 #else
     for(int i = sourceRays.begin(); i < sourceRays.end(); i++){
       destRays.setColor(i, color);
       destRays.setDirection(i, position - sourceRays.getHitPosition(i));
+      destRays.overrideMinT(1);
     }
 #endif
 }




  • [MANTA] r1412 - in trunk: Engine/Shadows Interface Model/Lights, bigler, 06/10/2007

Archive powered by MHonArc 2.6.16.

Top of page