Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r454 - branches/itanium2/Model/Materials


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r454 - branches/itanium2/Model/Materials
  • Date: Fri, 29 Jul 2005 00:44:51 -0600 (MDT)

Author: boulos
Date: Fri Jul 29 00:44:50 2005
New Revision: 454

Modified:
   branches/itanium2/Model/Materials/Dielectric.cc
Log:
Still more fixes to Dielectric code and removal
of old buggy code completely.  Without ray 
pruning this code is almost certainly to slow 
to use.


Modified: branches/itanium2/Model/Materials/Dielectric.cc
==============================================================================
--- branches/itanium2/Model/Materials/Dielectric.cc     (original)
+++ branches/itanium2/Model/Materials/Dielectric.cc     Fri Jul 29 00:44:50 
2005
@@ -37,52 +37,9 @@
 #include <Interface/Renderer.h>
 #include <Interface/Scene.h>
 #include <Interface/ShadowAlgorithm.h>
-#include <Core/Util/NotFinished.h>
-
-/* New Dielectric by P. Shirley 7/18
-   Notes:
-        1. just single ray packets for reflected and refracted rays
-        2. Assumes normal vector points toward n and away from nt
-        3. I removed shadow rays and phong highlight.  I am assuming
-           highlights will be in the background and specular rays
-           will thus create pseudo-highlights
-        4. I have an old version of Manta but I had to change sphere
-           to return hits beyond t=epsilon rather than t=0
-
-   Changes that should be made later:
-        1. compress rays into packets (espectially refraction rays)
-        2. add extinction (Beer's Law)
-        3. get rid of diffuse and specular constructor args
-*/
 
 using namespace Manta;
 
-#define USE_PETES_CODE 0
-
-//  Note-- both v and n must be unit vectors!
-// v is the incident vector and is rewritten
-bool Refract(const Vector& n, double ni, double nt, Vector& v)
-{
-    double  k;
-    Vector s;
-
-    k = Dot(v, n);
-    s = (ni/nt) * (v - k*n);
-    k = 1.0 - Dot(s,s);
-
-    if (k <  1.0e-6)
-    {
-        return false; // no refraction possible
-    }
-    else
-    {
-       v = s - sqrt(k)*n;
-       return true;
-    }
-}
-
-
-
 Dielectric::Dielectric(const Texture<Real>* n, const Texture<Real>* nt, 
const Texture<Color>* sigma_a)
     : n(n), nt(nt), sigma_a(sigma_a)
 {
@@ -130,18 +87,13 @@
   Vector refr_dirs[RayPacket::MaxSize];
   float fresnel_coeffs[RayPacket::MaxSize]; // might be better to compute
   bool internally_reflected[RayPacket::MaxSize];
-#if (!USE_PETES_CODE)
   bool apply_beers[RayPacket::MaxSize];
-#else
-  bool from_outsides[RayPacket::MaxSize];
-#endif
 
   int num_internal = 0;
   int num_branch   = 0;
 
   for(int i=0;i<rays.getSize();i++)
   {
-#if (!USE_PETES_CODE)
       RayPacket::Element& e = rays.get(i);
       Vector N = e.normal;
       double n_dot_v = Dot(N, e.ray.direction());
@@ -157,9 +109,10 @@
       else
       {
           N = -N;
-          eta_tmp = nt_values[i]/nt_values[i];
+          eta_tmp = nt_values[i]/n_values[i];
           eta_tmp_inv = 1.0 / eta_tmp;
       }
+
       apply_beers[i] = !was_incoming;
 
       double cosine = 1.0 + (n_dot_v*n_dot_v - 
1.0)*(eta_tmp_inv*eta_tmp_inv);
@@ -175,7 +128,7 @@
       {
           cosine = (cosine > 0) ? sqrt(cosine) : 0;
           double cos_min = ( cosine > n_dot_v ) ? n_dot_v : cosine;
-                    float k = 1 - cosine;
+          float k = 1 - cosine;
           k*=k*k*k*k;
 
           double r0 = (n_values[i] - nt_values[i]) / (n_values[i] + 
nt_values[i]);
@@ -191,65 +144,6 @@
           refr_dirs[i] = refr_dir;
           fresnel_coeffs[i] = R;
       }
-#else
-      RayPacket::Element& e = rays.get(i);
-      double cosine = -Dot(e.normal, e.ray.direction());
-
-      Vector refl_dir, refr_dir;
-      bool from_outside = (cosine > 0);
-      from_outsides[i] = from_outside;
-      bool total_internal_reflection;
-      refr_dir = e.ray.direction();
-      refl_dir = e.ray.direction() + 2 * cosine * e.normal;
-
-      if (from_outside)
-      {
-          // refract changes the refr_dir
-          total_internal_reflection = !Refract(e.normal,
-                                               n_values[i],
-                                               nt_values[i],
-                                               refr_dir);
-      }
-      else
-      {
-          total_internal_reflection = !Refract(-e.normal,
-                                               nt_values[i],
-                                               n_values[i],
-                                               refr_dir);
-          cosine = -cosine;
-      }
-
-      if (total_internal_reflection)
-      {
-          internally_reflected[i] = true;
-          num_internal++;
-          refl_dirs[i] = refl_dir;
-      }
-      else  // reflection and refraction
-      {
-          float cosine2;
-          if (from_outside) {
-              cosine2 = -Dot(e.normal, refr_dir);
-          }
-          else {
-              cosine2 = Dot(e.normal, refr_dir);
-          }
-
-          if (cosine2 < cosine) cosine = cosine2; // for Schlick
-          float k = 1 - cosine;
-          k*=k*k*k*k;
-
-          double r0 = (n_values[i] - nt_values[i]) / (n_values[i] + 
nt_values[i]);
-          r0 *= r0;
-          float R = r0*(1-k) + k;
-
-          internally_reflected[i] = false;
-          num_branch++;
-          refl_dirs[i] = refl_dir;
-          refr_dirs[i] = refr_dir;
-          fresnel_coeffs[i] = R;
-      }
-#endif
   }
 
   // okay we've got everything ready now
@@ -325,3 +219,4 @@
       }
   }
 }
+




  • [MANTA] r454 - branches/itanium2/Model/Materials, boulos, 07/29/2005

Archive powered by MHonArc 2.6.16.

Top of page