Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1323 - trunk/Engine/Shadows


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1323 - trunk/Engine/Shadows
  • Date: Wed, 4 Apr 2007 17:16:03 -0600 (MDT)

Author: bigler
Date: Wed Apr  4 17:16:02 2007
New Revision: 1323

Modified:
   trunk/Engine/Shadows/HardShadows.cc
   trunk/Engine/Shadows/HardShadows.h
Log:

Beginnings of attenuate shadows.  Don't try to use it yet.  There are
still some more things that need to be added.


Modified: trunk/Engine/Shadows/HardShadows.cc
==============================================================================
--- trunk/Engine/Shadows/HardShadows.cc (original)
+++ trunk/Engine/Shadows/HardShadows.cc Wed Apr  4 17:16:02 2007
@@ -7,6 +7,9 @@
 #include <Interface/RayPacket.h>
 #include <Interface/Scene.h>
 #include <MantaSSE.h>
+#include <Core/Exceptions/IllegalArgument.h>
+#include <Core/Util/Args.h>
+#include <Interface/Material.h>
 
 // TODO
 // 0 copy in light stuff
@@ -20,8 +23,19 @@
   return new HardShadows(args);
 }
 
-HardShadows::HardShadows(const vector<string>& /*args*/)
+HardShadows::HardShadows(const vector<string>& args)
+  : attenuateShadows(false)
 {
+  int argc = static_cast<int>(args.size());
+  for(int i = 0; i<argc;i++){
+    string arg = args[i];
+    if(arg == "-attenuate" || arg == "-attenuateShadows"){
+      attenuateShadows = true;
+    }
+    else {
+      throw IllegalArgument("HardShadows", i, args);
+    }
+  }
 }
 
 HardShadows::~HardShadows()
@@ -178,6 +192,53 @@
     shadowRays.setFlag( RayPacket::NormalizedDirections );
     shadowRays.resize ( last + 1);
     context.scene->getObject()->intersect(context, shadowRays);
+    if (attenuateShadows) {
+      bool raysActive = true;
+      Real cutoff = context.scene->getRenderParameters().importanceCutoff;
+      int currentDepth = shadowRays.getDepth();
+      int maxDepth = context.scene->getRenderParameters().maxDepth;
+      while (raysActive && (currentDepth < maxDepth)) {
+        // Those rays that did hit something, we need to compute the
+        // attenuation.
+
+        raysActive = false;
+        for(int i = shadowRays.begin();i<shadowRays.end();){
+          if(shadowRays.wasHit(i)){
+            const Material* hit_matl = shadowRays.getHitMaterial(i);
+            int end = i+1;
+            while(end < shadowRays.end() && shadowRays.wasHit(end) &&
+                  shadowRays.getHitMaterial(end) == hit_matl)
+              end++;
+            RayPacket subPacket(shadowRays, i, end);
+            hit_matl->attenuateShadows(context, subPacket);
+            i=end;
+          }
+        }
+
+        // If there are any rays left that have attenuation, create a
+        // new shadow ray and keep it going.
+        for(int i = shadowRays.begin();i<shadowRays.end();){
+          if(shadowRays.wasHit(i) &&
+             !shadowRays.getColor(i).luminance() > cutoff) {
+            if (!raysActive) {
+              raysActive = true;
+              currentDepth++;
+            }
+            int end = i+1;
+            while(end < shadowRays.end() &&
+                  shadowRays.wasHit(i) &&
+                  (!shadowRays.getColor(i).luminance() > cutoff))
+              end++;
+            // Change all the origins and reset the hits?
+            RayPacket subPacket(shadowRays, i, end);
+            subPacket.computeHitPositions();
+            context.scene->getObject()->intersect(context, subPacket);
+            i=end;
+          }
+        }
+
+      }
+    }
   }
 
   if(j == nlights){

Modified: trunk/Engine/Shadows/HardShadows.h
==============================================================================
--- trunk/Engine/Shadows/HardShadows.h  (original)
+++ trunk/Engine/Shadows/HardShadows.h  Wed Apr  4 17:16:02 2007
@@ -24,6 +24,8 @@
     virtual string getName() const;
     virtual string getSpecs() const;
 
+    // If true it will compute attenuated shadows
+    bool attenuateShadows;
   private:
     HardShadows(const HardShadows&);
     HardShadows& operator=(const HardShadows&);




  • [MANTA] r1323 - trunk/Engine/Shadows, bigler, 04/04/2007

Archive powered by MHonArc 2.6.16.

Top of page