Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r766 - in trunk: Core/Geometry Model/Cameras Model/Materials Model/Primitives SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r766 - in trunk: Core/Geometry Model/Cameras Model/Materials Model/Primitives SwigInterface
  • Date: Mon, 12 Dec 2005 13:48:07 -0700 (MST)

Author: bigler
Date: Mon Dec 12 13:48:06 2005
New Revision: 766

Modified:
   trunk/Core/Geometry/BBox.h
   trunk/Model/Cameras/PinholeCamera.cc
   trunk/Model/Materials/MetalMaterial.cc
   trunk/Model/Primitives/Ring.cc
   trunk/SwigInterface/runmanta.py
Log:

Core/Geometry/BBox.h

  Include Expon.h instead of MiscMath.h.

  Fix extendByDisc function.  It was computing v with p instead of n.
  Use Sqrt instead of sqrt for help with Real == float.

Model/Cameras/PinholeCamera.cc

  When there is an ambigous up direction, I want to see values from
  the member variables.

Model/Materials/MetalMaterial.cc

  Don't compute a bunch of stuff when max depth is reached.

  When max depth is reached set the colors to black, so there is
  something assigned and you don't get random noise.

Model/Primitives/Ring.cc

  You should use outer_radius instead of radius (which only gets you
  the inside radius) when computing the bounding box.

SwigInterface/runmanta.py

  Remove adding an extra ring that shouldn't have been there.


Modified: trunk/Core/Geometry/BBox.h
==============================================================================
--- trunk/Core/Geometry/BBox.h  (original)
+++ trunk/Core/Geometry/BBox.h  Mon Dec 12 13:48:06 2005
@@ -3,7 +3,7 @@
 #define Manta_Core_BBox_h
 
 #include <Core/Geometry/PointVector.h>
-#include <SCIRun/Core/Math/MiscMath.h>
+#include <SCIRun/Core/Math/Expon.h>
 
 #include <sgi_stl_warnings_off.h>
 #include <limits>
@@ -57,10 +57,14 @@
       bounds[0] = Min(bounds[0], p-Vector(radius, radius, radius));
       bounds[1] = Max(bounds[1], p+Vector(radius, radius, radius));
     }
+    // n really needs to be normalize, or you could get NaNs when
+    // taking the square root of a negative number.
     void extendByDisc(const Point& p, const Vector& n, Real radius) {
-      Vector v(sqrt(1-p.x()*p.x()), sqrt(1-p.y()*p.y()), 
sqrt(1-p.z()*p.z()));
-      bounds[0] = Min(bounds[0], p-v*radius);
-      bounds[1] = Max(bounds[1], p+v*radius);
+      Vector v(SCIRun::Sqrt(1-n.x()*n.x())*radius,
+               SCIRun::Sqrt(1-n.y()*n.y())*radius,
+               SCIRun::Sqrt(1-n.z()*n.z())*radius);
+      bounds[0] = Min(bounds[0], p-v);
+      bounds[1] = Max(bounds[1], p+v);
     }
     void extendByBox(const BBox& b) {
       bounds[0] = Min(bounds[0], b.bounds[0]);

Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc        (original)
+++ trunk/Model/Cameras/PinholeCamera.cc        Mon Dec 12 13:48:06 2005
@@ -103,7 +103,15 @@
 
   v=Cross(direction, up);
   if(v.length2() == 0){
-    std::cerr << __FILE__ << " line: " << __LINE__ << " Ambiguous up 
direciton...\n";
+    std::cerr << __FILE__ << " line: " << __LINE__
+              << " Ambiguous up direciton... "
+              << "lookat = "<< lookat
+              << ", eye = "<< eye
+              << ", direciton = "<< direction
+              << ", n = " << n
+              << ", up = "<< up
+              << ", v = " << v
+              << "\n";
   }
   v.normalize();
 

Modified: trunk/Model/Materials/MetalMaterial.cc
==============================================================================
--- trunk/Model/Materials/MetalMaterial.cc      (original)
+++ trunk/Model/Materials/MetalMaterial.cc      Mon Dec 12 13:48:06 2005
@@ -31,46 +31,50 @@
 
 void MetalMaterial::shade(const RenderContext& context, RayPacket& rays) 
const
 {
-  rays.normalizeDirections();
-  rays.computeNormals(context);
-  Color specular[RayPacket::MaxSize];
-  specular_reflectance->mapValues(context, rays, specular);
+  // Compute only if we haven't hit the max ray depth.
+  if(rays.getDepth() < context.scene->getRenderParameters().maxDepth) {
+    rays.normalizeDirections();
+    rays.computeNormals(context);
+    Color specular[RayPacket::MaxSize];
+    specular_reflectance->mapValues(context, rays, specular);
   
-  // Compute reflections
-  if(rays.getDepth() < context.scene->getRenderParameters().maxDepth)
-  {
     rays.computeHitPositions();
     RayPacketData rdata;
     RayPacket refl_rays(rdata, rays.getSize(), rays.getDepth()+1,
-                       RayPacket::NormalizedDirections);
+                        RayPacket::NormalizedDirections);
     refl_rays.useLocalColors();
     for(int i=0;i<rays.getSize();i++)
-    {  
-         RayPacket::Element& e = rays.get(i);
-         Vector refl_dir = e.ray.direction() - e.normal*(2*Dot(e.normal, 
e.ray.direction()));
-         RayPacket::Element& r = refl_rays.get(i);
-         r.ray.set(e.hitPosition,  refl_dir);
-    }
+      {  
+        RayPacket::Element& e = rays.get(i);
+        Vector refl_dir = e.ray.direction() - e.normal*(2*Dot(e.normal, 
e.ray.direction()));
+        RayPacket::Element& r = refl_rays.get(i);
+        r.ray.set(e.hitPosition,  refl_dir);
+      }
     
     refl_rays.resetHit();
     context.renderer->traceRays(context, refl_rays);
     for(int i=0;i<rays.getSize();i++) {
-       RayPacket::Element& e = rays.get(i);
-       RayPacket::Element& r = refl_rays.get(i);
+      RayPacket::Element& e = rays.get(i);
+      RayPacket::Element& r = refl_rays.get(i);
 
-       // compute Schlick Fresnel approximation
-       Real cosine = -Dot(e.normal, e.ray.direction());
-       if(cosine < 0) cosine =-cosine;
-       Real k = 1 - cosine;
-       k*=k*k*k*k;
+      // compute Schlick Fresnel approximation
+      Real cosine = -Dot(e.normal, e.ray.direction());
+      if(cosine < 0) cosine =-cosine;
+      Real k = 1 - cosine;
+      k*=k*k*k*k;
 
-       // Doing the explicit cast to ColorComponent here, so that we
-       // don't do things like multiply all the colors by a double,
-       // thus promoting those expressions when we don't need to.
-       ColorComponent kc = (ColorComponent)k;
-       Color R = specular[i] * (1-kc) + Color::white()*kc;
+      // Doing the explicit cast to ColorComponent here, so that we
+      // don't do things like multiply all the colors by a double,
+      // thus promoting those expressions when we don't need to.
+      ColorComponent kc = (ColorComponent)k;
+      Color R = specular[i] * (1-kc) + Color::white()*kc;
 
-        *e.color = R * (*r.color);
+      *e.color = R * (*r.color);
+    }
+  } else {
+    // Stuff black in it.
+    for(int i=0;i<rays.getSize();i++) {
+      rays.setResult(i, Color::black());
     }
   }
 }

Modified: trunk/Model/Primitives/Ring.cc
==============================================================================
--- trunk/Model/Primitives/Ring.cc      (original)
+++ trunk/Model/Primitives/Ring.cc      Mon Dec 12 13:48:06 2005
@@ -51,7 +51,7 @@
 
 void Ring::computeBounds(const PreprocessContext&, BBox& bbox) const
 {
-  bbox.extendByDisc(center, normal, SCIRun::Sqrt(radius2));
+  bbox.extendByDisc(center, normal, SCIRun::Sqrt(outer_radius2));
 }
 
 void Ring::intersect(const RenderContext&, RayPacket& rays) const

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Mon Dec 12 13:48:06 2005
@@ -61,7 +61,6 @@
     inner_radius = r*0.5
     center = Point(-6, 0, 2.5+r)
     offset = Vector(2.25*r, 0, 0);
-    ring = Ring(ringmatl, center, Vector(0.2, -1, -0.2), 0.5, 1)
     for i in range(9):
         world.add(manta_new(Ring(ringmatl,
                                  center+offset*i,




  • [MANTA] r766 - in trunk: Core/Geometry Model/Cameras Model/Materials Model/Primitives SwigInterface, bigler, 12/12/2005

Archive powered by MHonArc 2.6.16.

Top of page