Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1756 - in trunk: Engine/Renderers Interface


Chronological Thread 
  • From: arobison@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r1756 - in trunk: Engine/Renderers Interface
  • Date: Fri, 5 Oct 2007 15:47:52 -0600 (MDT)

Author: arobison
Date: Fri Oct  5 15:47:52 2007
New Revision: 1756

Modified:
   trunk/Engine/Renderers/Raytracer.cc
   trunk/Engine/Renderers/Raytracer.h
   trunk/Interface/Renderer.cc
   trunk/Interface/Renderer.h
Log:
Adding a three-argument traceRays() method to Renderer that
takes as its third parameter a Real importance cutoff and will
not trace rays whose importance luminance is below that cutoff.

The two-argument traceRays() will query the scene's importanceCutoff
and call the three-argument version of that value is greater
than zero.  However, that call is currently comment out due to
a large performance hit.  This is likely a bug hiding somewhere else.


Modified: trunk/Engine/Renderers/Raytracer.cc
==============================================================================
--- trunk/Engine/Renderers/Raytracer.cc (original)
+++ trunk/Engine/Renderers/Raytracer.cc Fri Oct  5 15:47:52 2007
@@ -52,6 +52,15 @@
   rays.resetHits();
   context.scene->getObject()->intersect(context, rays);
 
+#if 0
+  // grab the scene's importance cutoff for ray-tree attenuation
+  Real cutoff = context.scene->getRenderParameters().importanceCutoff;
+  if(cutoff > 0) {
+    traceRays(context, rays, cutoff);
+    return;    
+  }
+#endif
+
   // Go through the ray packet and shade them.  Group rays that hit the
   // same object and material to shade with a single shade call
   for(int i = rays.begin();i<rays.end();){
@@ -78,6 +87,65 @@
     } else {
       int end = i+1;
       while(end < rays.end() && !rays.wasHit(end))
+        end++;
+      if (debugFlag) {
+        for (int j = i; j < end; ++j) {
+          cerr << "raytree: ray_index "<<j
+               << " depth " << rays.getDepth()
+               << " origin "<< rays.getOrigin(j)
+               << " direction "<< rays.getDirection(j)
+               << "\n";
+        }
+      }
+      RayPacket subPacket(rays, i, end);
+      context.scene->getBackground()->shade(context, subPacket);
+      i=end;
+    }
+  }
+}
+
+void Raytracer::traceRays(const RenderContext& context, RayPacket& rays, 
Real cutoff)
+{
+  int debugFlag = rays.getAllFlags() & RayPacket::DebugPacket;
+  rays.resetHits();
+  context.scene->getObject()->intersect(context, rays);
+
+  // Go through the ray packet and shade them.  Group rays that hit the
+  // same object and material to shade with a single shade call
+  for(int i = rays.begin();i<rays.end();){
+
+    // skip rays that are below the importance threshold
+    if(rays.getImportance(i).luminance() < cutoff) {
+      i++;
+      continue;
+    }
+
+
+    if(rays.wasHit(i)){
+      const Material* hit_matl = rays.getHitMaterial(i);
+      int end = i+1;
+      while(end < rays.end() && rays.wasHit(end) &&
+            rays.getHitMaterial(end) == hit_matl &&
+           rays.getImportance(end).luminance() >= cutoff)
+        end++;
+      if (debugFlag) {
+        rays.computeHitPositions();
+        for (int j = i; j < end; ++j) {
+          cerr << "raytree: ray_index "<<j
+               << " depth " << rays.getDepth()
+               << " origin "<< rays.getOrigin(j)
+               << " direction "<< rays.getDirection(j)
+               << " hitpos " << rays.getHitPosition(j)
+               << "\n";
+        }
+      }
+      RayPacket subPacket(rays, i, end);
+      hit_matl->shade(context, subPacket);
+      i=end;
+    } else {
+      int end = i+1;
+      while(end < rays.end() && !rays.wasHit(end) &&
+           rays.getImportance(end).luminance() >= cutoff)
         end++;
       if (debugFlag) {
         for (int j = i; j < end; ++j) {

Modified: trunk/Engine/Renderers/Raytracer.h
==============================================================================
--- trunk/Engine/Renderers/Raytracer.h  (original)
+++ trunk/Engine/Renderers/Raytracer.h  Fri Oct  5 15:47:52 2007
@@ -23,6 +23,7 @@
 
     virtual void traceEyeRays(const RenderContext&, RayPacket& rays);
     virtual void traceRays(const RenderContext&, RayPacket& rays);
+    virtual void traceRays(const RenderContext&, RayPacket& rays, Real 
cutoff);
 
     static Renderer* create(const vector<string>& args);
   private:

Modified: trunk/Interface/Renderer.cc
==============================================================================
--- trunk/Interface/Renderer.cc (original)
+++ trunk/Interface/Renderer.cc Fri Oct  5 15:47:52 2007
@@ -1,5 +1,7 @@
 
 #include <Interface/Renderer.h>
+#include <Interface/Context.h>
+#include <Interface/RayPacket.h>
 
 using namespace Manta;
 
@@ -9,5 +11,10 @@
 
 Renderer::~Renderer()
 {
+}
+
+void Renderer::traceRays(const RenderContext& context, RayPacket& rays, Real 
cutoff)
+{
+  traceRays(context, rays);
 }
 

Modified: trunk/Interface/Renderer.h
==============================================================================
--- trunk/Interface/Renderer.h  (original)
+++ trunk/Interface/Renderer.h  Fri Oct  5 15:47:52 2007
@@ -2,6 +2,8 @@
 #ifndef Manta_Interface_Renderer_h
 #define Manta_Interface_Renderer_h
 
+#include <MantaTypes.h>
+
 namespace Manta {
   class SetupContext;
   class RenderContext;
@@ -15,6 +17,7 @@
 
     virtual void traceEyeRays(const RenderContext&, RayPacket& rays) = 0;
     virtual void traceRays(const RenderContext&, RayPacket& rays) = 0;
+    virtual void traceRays(const RenderContext&, RayPacket& rays, Real 
cutoff);
   protected:
     Renderer();
   private:




  • [Manta] r1756 - in trunk: Engine/Renderers Interface, arobison, 10/05/2007

Archive powered by MHonArc 2.6.16.

Top of page