Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2247 - trunk/Engine/Renderers


Chronological Thread 
  • From: roni@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2247 - trunk/Engine/Renderers
  • Date: Mon, 5 May 2008 00:49:26 -0600 (MDT)

Author: roni
Date: Mon May  5 00:49:25 2008
New Revision: 2247

Modified:
   trunk/Engine/Renderers/NPREdges.cc
Log:
Engine/Renderers/NPREdges.cc:

Added self-occluding silhouette edges.  Try this:

bin/manta -np 2 -scene "lib/libscene_primtest(-num 1x1 torus -material 
redlambertian -nobgpoly)" -camera "pinhole( -eye 3.89887 -4.45263 1.79552 
-lookat 0 0 0 -up -0.178942 0.229143 0.956804 -hfov 60 -vfov 60 
-normalizeRays )" -renderer "edges(-noshade)"



Modified: trunk/Engine/Renderers/NPREdges.cc
==============================================================================
--- trunk/Engine/Renderers/NPREdges.cc  (original)
+++ trunk/Engine/Renderers/NPREdges.cc  Mon May  5 00:49:25 2008
@@ -212,26 +212,53 @@
         normDown.computeFFNormals(context);
 
         for(int k=i; k<j; k++){
+          bool checkSelfOccluding = true;
+
           const Primitive *hitprim = rays.getHitPrimitive(k);
-          if(!creasable(hitprim))
-            continue;
+          if(creasable(hitprim)){
+            // Compute the gradient of the normal field.
+            const Vector v1 = normRight.getFFNormal(k) - 
normLeft.getFFNormal(k);
+            const Vector v2 = normUp.getFFNormal(k) - 
normDown.getFFNormal(k);
+
+            if(debugFlag){
+              cerr << "right normal: " << normRight.getFFNormal(k) << endl
+                   << "left normal: " << normLeft.getFFNormal(k) << endl
+                   << "up normal: " << normUp.getFFNormal(k) << endl
+                   << "down normal: " << normDown.getFFNormal(k) << endl
+                   << "v1 (right minus left): " << v1 << endl
+                   << "v2 (right minus left): " << v2 << endl;
+            }
 
-          // Compute the gradient of the normal field.
-          const Vector v1 = normRight.getFFNormal(k) - 
normLeft.getFFNormal(k);
-          const Vector v2 = normUp.getFFNormal(k) - normDown.getFFNormal(k);
-
-          if(debugFlag){
-            cerr << "right normal: " << normRight.getFFNormal(k) << endl
-                 << "left normal: " << normLeft.getFFNormal(k) << endl
-                 << "up normal: " << normUp.getFFNormal(k) << endl
-                 << "down normal: " << normDown.getFFNormal(k) << endl
-                 << "v1 (right minus left): " << v1 << endl
-                 << "v2 (right minus left): " << v2 << endl;
+            if(v1.length2() + v2.length2() > normalThreshold){
+              rays.setColor(k, Color::black());
+              checkSelfOccluding = false;
+            }
           }
 
-          if(v1.length2() + v2.length2() > normalThreshold){
-            rays.setColor(k, Color::black());
+          if(checkSelfOccluding){
+            const Real t = rays.getMinT(k);
+
+            // Count the number of stencil rays whose t-values are far
+            // from the t-value of the sample ray.
+            int count = 0;
+            for(int l=0; l<stencil_size; l++){
+              const Real diff = Abs(t - stencil[l].getMinT(k));
+              // NOTE(choudhury): the value by which to scale t is
+              // arbitrary.  0.16667 and 0.2 both work well for the
+              // torus as it appears in the primtest scene.
+
+              //const Real threshold = 0.16667*t;
+              const Real threshold = 0.2*t;
+              if(debugFlag){
+                std::cout << "diff[" << l << "] = " << diff << (diff > 
threshold ? " [check]" : "") << std::endl;
+              }
+              count = diff > threshold ? count + 1 : count;
+            }
+
+            float lightness = Abs(count - stencil_size/2.0) / 
(stencil_size/2.0);
+            rays.setColor(k, rays.getColor(k)*lightness);
           }
+
         }
 
         i = j;




  • [Manta] r2247 - trunk/Engine/Renderers, roni, 05/05/2008

Archive powered by MHonArc 2.6.16.

Top of page