Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1104 - in trunk: Model/Backgrounds scenes


Chronological Thread 
  • From: cgribble@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1104 - in trunk: Model/Backgrounds scenes
  • Date: Thu, 8 Jun 2006 11:57:38 -0600 (MDT)

Author: cgribble
Date: Thu Jun  8 11:57:37 2006
New Revision: 1104

Modified:
   trunk/Model/Backgrounds/EnvMapBackground.cc
   trunk/scenes/pnrrd.cc
Log:
Model/Backgrounds/EnvMapBackground.cc
  Reformulated the mapping to reduce some operations
  Found and fixed the "seam" bug --> the two test images I was using both had 
a
    stray column of pixels on the left edge of the image!  Go figure...

scenes/pnrrd.cc
  Added a bookmark for the "seam" bug above


Modified: trunk/Model/Backgrounds/EnvMapBackground.cc
==============================================================================
--- trunk/Model/Backgrounds/EnvMapBackground.cc (original)
+++ trunk/Model/Backgrounds/EnvMapBackground.cc Thu Jun  8 11:57:37 2006
@@ -8,6 +8,7 @@
 
 using namespace Manta;
 
+static Real OneOverPi=static_cast<Real>(1/M_PI);
 static Real OneOverTwoPi=static_cast<Real>(1/(2*M_PI));
 static Real PiOverTwo=static_cast<Real>(M_PI/2);
 
@@ -17,8 +18,9 @@
   // Create an image texture
   Image* ppmImage=readPPM(filename);
   image=new ImageTexture<Color>(ppmImage);
-  image->setInterpolationMethod(ImageTexture<Color>::Bilinear);
-  image->setVEdgeBehavior(ImageTexture<Color>::Clamp);
+  // image->setInterpolationMethod(ImageTexture<Color>::Bilinear);
+  // image->setUEdgeBehavior(ImageTexture<Color>::Wrap);
+  // image->setVEdgeBehavior(ImageTexture<Color>::Clamp);
 
   // Initialize an orthonormal basis
   U=right.normal();
@@ -41,6 +43,28 @@
 {
   for (int i=rays.begin(); i<rays.end(); ++i) {
     const Vector inDir(rays.getDirection(i));
+#if 1
+    // Note:  Don't invert ray direction during projection into the 
cylindrical
+    //   basis ...
+    Vector dir(Dot(inDir, U), Dot(inDir, V), Dot(inDir, W));
+    VectorT<Real, 2> texcoords;
+
+    // Compute and scale u
+    //   ... and simply invert the y component here
+    //
+    //   result of Atan2(-y, x) is arctan(y/x) with the quadrant determined 
by
+    //     signs of both arguments, so it is in [-Pi, Pi]
+    //   result + Pi is in [0, TwoPi]
+    //   result/TwoPi is in [0, 1]
+    texcoords[0]=(Atan2(-dir.y(), dir.x()) + Pi)*OneOverTwoPi;
+
+    // Compute and scale v
+    //   ... and simply scale by 1/Pi to get v in [0, 1]
+    //
+    //   result of Acos(z) is in [0, Pi]
+    //   1/Pi*result is in [0, 1]
+    texcoords[1]=Acos(dir.z())*OneOverPi;
+#else
     Vector dir(-Dot(inDir, U), -Dot(inDir, V), -Dot(inDir, W));
     VectorT<Real, 2> texcoords;
 
@@ -58,6 +82,7 @@
     //   1 + result is in [0, 2]
     //   0.5*result is in [0, 1]
     texcoords[1]=0.5*(1 + Sin(PiOverTwo - Acos(dir.z())));
+#endif
 
     rays.setTexCoords(i, texcoords);
   }

Modified: trunk/scenes/pnrrd.cc
==============================================================================
--- trunk/scenes/pnrrd.cc       (original)
+++ trunk/scenes/pnrrd.cc       Thu Jun  8 11:57:37 2006
@@ -106,6 +106,9 @@
   scene->setLights(lights);
 
   /*
+  scene->addBookmark("envmap debug", Vector(0.155849, 0.427053, 0.207308),
+                     Vector(-0.0575852, 0.370596, 0.0405846),
+                     Vector(-0.615144, -0.00271556, 0.78841), 50.4702);
   scene->addBookmark("debug 0", Vector(0.06, 26.9721, 0.06),
                      Vector(0.06, 0.06, 0.06), Vector(0, 0, 1), 0.59);
   scene->addBookmark("debug 1", Vector(-10.3318,-2.88089, 24.71),




  • [MANTA] r1104 - in trunk: Model/Backgrounds scenes, cgribble, 06/08/2006

Archive powered by MHonArc 2.6.16.

Top of page