Manta Interactive Ray Tracer Development Mailing List

Text archives Help


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


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r450 - branches/itanium2/Model/Materials
  • Date: Thu, 28 Jul 2005 03:16:58 -0600 (MDT)

Author: boulos
Date: Thu Jul 28 03:16:57 2005
New Revision: 450

Modified:
   branches/itanium2/Model/Materials/Dielectric.cc
Log:
Making beer's law conditional on actually
transmitting through the medium.


Modified: branches/itanium2/Model/Materials/Dielectric.cc
==============================================================================
--- branches/itanium2/Model/Materials/Dielectric.cc     (original)
+++ branches/itanium2/Model/Materials/Dielectric.cc     Thu Jul 28 03:16:57 
2005
@@ -1,11 +1,11 @@
 /*
  For more information, please see: http://software.sci.utah.edu

+
  The MIT License

+
  Copyright (c) 2005
  Scientific Computing and Imaging Institute, University of Utah.

+
  License for the specific language governing rights and limitations under
  Permission is hereby granted, free of charge, to any person obtaining a
  copy of this software and associated documentation files (the "Software"),
@@ -13,10 +13,10 @@
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
  and/or sell copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following conditions:

+
  The above copyright notice and this permission notice shall be included
  in all copies or substantial portions of the Software.

+
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -124,10 +124,12 @@
   nt->mapValues(context, rays, nt_values);
   sigma_a->mapValues(context, rays, sigma_a_values);
 
-  bool internally_reflected[RayPacket::MaxSize];
   Vector refl_dirs[RayPacket::MaxSize];
   Vector refr_dirs[RayPacket::MaxSize];
   float fresnel_coeffs[RayPacket::MaxSize]; // might be better to compute
+  bool internally_reflected[RayPacket::MaxSize];
+  bool from_outsides[RayPacket::MaxSize];
+
   int num_internal = 0;
   int num_branch   = 0;
 
@@ -137,6 +139,7 @@
       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;
@@ -241,10 +244,14 @@
       if (internally_reflected[i])
       {
           RayPacket::Element& r = internal_rays.get(internal_counter);
-          // These two Beer's law calculations are equivalent, but
-          // one may be faster than the other
-          //(*r.color) *= 
sigma_a_values[i].Log().attenuate(r.hitInfo.minT());
-          (*r.color) *= sigma_a_values[i].Pow(r.hitInfo.minT());
+
+          if ( !from_outsides[internal_counter] )
+          {
+              // These two Beer's law calculations are equivalent, but
+              // one may be faster than the other
+              //(*r.color) *= 
sigma_a_values[i].Log().attenuate(r.hitInfo.minT());
+              (*r.color) *= sigma_a_values[i].Pow(r.hitInfo.minT());
+          }
           rays.setResult(i, *r.color);
           internal_counter++;
       }
@@ -252,10 +259,14 @@
       {
           RayPacket::Element& refl = reflected_rays.get(branch_counter);
           RayPacket::Element& refr = refracted_rays.get(branch_counter);
-          // These two Beer's law calculations are equivalent, but
-          // one may be faster than the other
-          //(*refr.color) *= 
sigma_a_values[i].Log().attenuate(refr.hitInfo.minT());
-          (*refr.color) *= sigma_a_values[i].Pow(refr.hitInfo.minT());
+
+          if ( from_outsides[branch_counter] )
+          {
+              // These two Beer's law calculations are equivalent, but
+              // one may be faster than the other
+              //(*refr.color) *= 
sigma_a_values[i].Log().attenuate(refr.hitInfo.minT());
+              (*refr.color) *= sigma_a_values[i].Pow(refr.hitInfo.minT());
+          }
           rays.setResult(i, (Color::white()*fresnel_coeffs[i])*(*refl.color) 
+
                          
(Color::white()*(1.-fresnel_coeffs[i]))*(*refr.color) );
           branch_counter++;




  • [MANTA] r450 - branches/itanium2/Model/Materials, boulos, 07/28/2005

Archive powered by MHonArc 2.6.16.

Top of page