Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1414 - in trunk: Core/Math Interface Model/Primitives StandAlone


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1414 - in trunk: Core/Math Interface Model/Primitives StandAlone
  • Date: Mon, 11 Jun 2007 18:16:58 -0600 (MDT)

Author: boulos
Date: Mon Jun 11 18:16:57 2007
New Revision: 1414

Modified:
   trunk/Core/Math/SSEDefs.cc
   trunk/Interface/RayPacket.cc
   trunk/Interface/RayPacket.h
   trunk/Model/Primitives/CMakeLists.txt
   trunk/StandAlone/manta.cc
Log:
"Fixing" __m128i ostream output (i love compilers)

Fixing texture coordinate lookups in ray packet.


Modified: trunk/Core/Math/SSEDefs.cc
==============================================================================
--- trunk/Core/Math/SSEDefs.cc  (original)
+++ trunk/Core/Math/SSEDefs.cc  Mon Jun 11 18:16:57 2007
@@ -19,9 +19,15 @@
   // single version.
   std::ostream& operator<<(std::ostream& os, __m128i t)
   {
-    MANTA_ALIGN(16) int i[4];
-    _mm_store_si128((__m128i*)&i[0],t);
-    os << i[0] << ", " << i[1] << ", " << i[2] << ", " << i[3];
+     //MANTA_ALIGN(16) int i[4];
+     //_mm_store_si128((__m128i*)&i[0],t);
+     //os << "__m128i = " << i[0] << ", " << i[1] << ", " << i[2] << ", " << 
i[3];
+     os << "__m128 = ";
+     for (int i = 0; i < 4; i++) {
+        os << ((int*)&t)[i];
+        if (i != 3)
+           os << ", ";
+     }
     return os;
   }
 #endif

Modified: trunk/Interface/RayPacket.cc
==============================================================================
--- trunk/Interface/RayPacket.cc        (original)
+++ trunk/Interface/RayPacket.cc        Mon Jun 11 18:16:57 2007
@@ -187,8 +187,40 @@
       setFFNormal(i,  normal);
     else
       setFFNormal(i, -normal);
-                  
+
   }
 
   flags |= HaveFFNormals;
+}
+
+void RayPacket::actualComputeTextureCoordinates2(const RenderContext& 
context)
+{
+  // Compute texture coordinates
+  for(int i=rayBegin;i<rayEnd;){
+    const TexCoordMapper* tex = data->hitTex[i];
+    int tend = i+1;
+    while(tend < rayEnd && data->hitTex[tend] == tex)
+      tend++;
+    RayPacket subPacket(*this, i, tend);
+    tex->computeTexCoords2(context, subPacket);
+    i=tend;
+  }
+
+  flags |= HaveTexture2;
+}
+
+void RayPacket::actualComputeTextureCoordinates3(const RenderContext& 
context)
+{
+  // Compute texture coordinates
+  for(int i=rayBegin;i<rayEnd;){
+    const TexCoordMapper* tex = data->hitTex[i];
+    int tend = i+1;
+    while(tend < rayEnd && data->hitTex[tend] == tex)
+      tend++;
+    RayPacket subPacket(*this, i, tend);
+    tex->computeTexCoords3(context, subPacket);
+    i=tend;
+  }
+
+  flags |= HaveTexture3;
 }

Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Mon Jun 11 18:16:57 2007
@@ -124,7 +124,7 @@
   public:
     enum RayPacketSizes {
       MaxSize               = RayPacketData::MaxSize,
-      
+
 #ifdef MANTA_SSE
       SSE_MaxSize           = RayPacketData::SSE_MaxSize,
 #endif
@@ -493,7 +493,7 @@
         // Some of them hit, some of them do not
         // Intel has a masked move instruction but it seems to be really slow
         // It is faster to load the old data and mask it in manually
-        _mm_store_ps(&data->minT[start], 
+        _mm_store_ps(&data->minT[start],
                      _mm_or_ps(_mm_and_ps(mask, t),
                                _mm_andnot_ps(mask, 
_mm_load_ps(&data->minT[start]))));
 #ifdef __x86_64
@@ -575,7 +575,7 @@
     }
 
 #endif // #ifdef MANTA_SSE
-      
+
     bool wasHit(int which)
     {
       return data->hitMatl[which] != 0;
@@ -608,7 +608,7 @@
 #else // __x86_64
       return  
_mm_castsi128_ps(_mm_cmpeq_epi32(_mm_load_si128((__m128i*)&data->hitMatl[start]),
                                                _mm_setzero_si128()));
-      
+
 #endif // __x86_64
     }
     ///////////////////////////////////////////////////////////
@@ -704,22 +704,17 @@
       return data->texCoords[dim][which];
     }
 
-    // These aren't right - the texture object may not be consecutive
     void computeTextureCoordinates2(const RenderContext& context)
     {
       if(flags & (HaveTexture2|HaveTexture3))
         return;
-      const TexCoordMapper* tex = data->hitTex[rayBegin];
-      tex->computeTexCoords2(context, *this);
-      flags |= HaveTexture2;
+      actualComputeTextureCoordinates2(context);
     }
     void computeTextureCoordinates3(const RenderContext& context)
     {
       if(flags & HaveTexture3)
         return;
-      const TexCoordMapper* tex = data->hitTex[rayBegin];
-      tex->computeTexCoords3(context, *this);
-      flags |= HaveTexture2|HaveTexture3;
+      actualComputeTextureCoordinates3(context);
     }
 
 
@@ -773,7 +768,7 @@
     {
       if(flags & HaveHitPositions)
         return;
-      
+
       actualComputeHitPositions();
     }
 
@@ -810,6 +805,8 @@
     void actualComputeHitPositions();
     void actualComputeNormals(const RenderContext& context);
     void actualComputeFFNormals(const RenderContext& context);
+    void actualComputeTextureCoordinates2(const RenderContext& context);
+    void actualComputeTextureCoordinates3(const RenderContext& context);
 
     // Prevent accidental copying of RayPackets
     RayPacket(const RayPacket&);

Modified: trunk/Model/Primitives/CMakeLists.txt
==============================================================================
--- trunk/Model/Primitives/CMakeLists.txt       (original)
+++ trunk/Model/Primitives/CMakeLists.txt       Mon Jun 11 18:16:57 2007
@@ -36,6 +36,8 @@
      Primitives/Sphere.h
      Primitives/SuperEllipsoid.cc
      Primitives/SuperEllipsoid.h
+     Primitives/superellipsoid.cc
+     Primitives/superellipsoid.h
      Primitives/TessellatedCylinder.cc
      Primitives/TessellatedCylinder.h
      Primitives/TexTriangle.cc

Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc   (original)
+++ trunk/StandAlone/manta.cc   Mon Jun 11 18:16:57 2007
@@ -72,6 +72,8 @@
 #include <iostream>
 #include <sgi_stl_warnings_on.h>
 
+#include <Model/Primitives/superellipsoid.h>
+
 using namespace std;
 using namespace Manta;
 using SCIRun::InternalError;
@@ -103,13 +105,13 @@
 {
 
   cerr << "Manta Interactive Ray Tracer" << "\n\n";
-  
+
   cerr << getLicenseString() << "\n";
-    
+
   cerr << "Revision information:\n";
-  
+
   cerr << getAboutString() << "\n\n";
-  
+
   cerr << "Usage: manta [options]\n";
   cerr << "Valid options are:\n";
   cerr << " -help           - Print this message and exit\n";
@@ -151,7 +153,7 @@
   BenchHelper(MantaInterface* rtrt, long numFrames, bool verbose);
   void start(int, int);
   void stop(int, int);
-       
+
 private:
   MantaInterface* rtrt;
   double startTime;
@@ -196,7 +198,7 @@
   vector<string> args;
   for(int i=1;i<argc;i++)
     args.push_back(argv[i]);
-       
+
   try {
 
     
///////////////////////////////////////////////////////////////////////////
@@ -205,7 +207,7 @@
 
     // Create a Manta Factory.
     factory = new Factory( rtrt );
-    
+
     // Set the scene search path based on an env variable.
     if(getenv("MANTA_SCENEPATH"))
       factory->setScenePath(getenv("MANTA_SCENEPATH"));
@@ -218,10 +220,10 @@
     // Default options.
     if(!factory->selectImageType("argb8"))
       throw InternalError("default image not found", __FILE__, __LINE__);
-    
+
     if(!factory->selectShadowAlgorithm("hard"))
       throw InternalError("default shadow algorithm not found", __FILE__, 
__LINE__ );
-    
+
     // Set camera for the default scene.
     Camera* currentCamera = factory->createCamera("pinhole(-normalizeRays)");
     if(!currentCamera)
@@ -238,7 +240,7 @@
     Color bgcolor;
     bool override_scene_bgcolor = false;
     int maxDepth = -1;          // -1 is invalid and represent unset state.
-    
+
 
     // Parse command line args.
     try {
@@ -247,13 +249,13 @@
         if(arg == "-help"){
           usage(factory);
 
-        
+
         } else if(arg == "-bench" ||
                   arg == "-quietbench" ||
                   arg == "-nodisplaybench") {
 
           
///////////////////////////////////////////////////////////////////////
-          // Benchmark Helper.        
+          // Benchmark Helper.
           bool verbose = true;
           if(arg == "-quietbench")
             verbose = false;
@@ -280,7 +282,7 @@
             ui->startup();
             haveUI = true;
           }
-        
+
         } else if(arg == "-camera"){
           string s;
           if(!getStringArg(i, args, s))
@@ -298,7 +300,7 @@
           }
         } else if(arg == "-stereo") {
           stereo = true;
-        
+
         } else if(arg == "-imagedisplay"){
           string s;
           if(!getStringArg(i, args, s))
@@ -307,10 +309,10 @@
           // Create the channel.
           try {
             ImageDisplay *display = factory->createImageDisplay( s );
-            
+
             rtrt->createChannel(display, currentCamera, stereo, xres, yres);
-            
-            
+
+
           } catch (UnknownComponent e) {
             cerr << e.message() << "\n"
                  << "Available image displays: ";
@@ -327,8 +329,8 @@
             cerr << "Invalid image type: " << s << ", available image types 
are:\n";
             printList(cerr, factory->listImageTypes());
             throw IllegalArgument( s, i, args );
-          }        
-        
+          }
+
         } else if(arg == "-idlemode"){
           string s;
           if(!getStringArg(i, args, s))
@@ -343,7 +345,7 @@
           if(!getLongArg(i, args, np))
             usage(factory);
           rtrt->changeNumWorkers(static_cast<int>(np));
-        
+
         } else if(arg == "-ui"){
           string s;
           if(!getStringArg(i, args, s))
@@ -366,7 +368,7 @@
             printList(cerr, factory->listShadowAlgorithms());
             throw IllegalArgument( s, i, args );
           }
-        
+
         } else if(arg == "-scene"){
           if(rtrt->getScene()!=0)
             cerr << "WARNING: multiple scenes specified, will use last 
one\n";
@@ -416,13 +418,13 @@
     catch (SCIRun::Exception& e) {
       cerr << "manta.cc (argument parsing): Caught SCIRun exception: " << 
e.message() << '\n';
       Thread::exitAll( 1 );
-      
+
     } catch (std::exception e){
       cerr << "manta.cc (argument parsing): Caught std exception: "
            << e.what()
            << '\n';
       Thread::exitAll(1);
-      
+
     } catch(...){
       cerr << "manta.cc (argument parsing): Caught unknown exception\n";
       Thread::exitAll(1);
@@ -441,8 +443,8 @@
     if(!haveUI){
       UserInterface* ui = factory->createUserInterface("X");
       if(!ui){
-                               cerr << "Cannot find default user interface: 
X, available user interfaces are:\n";
-                               printList(cerr, 
factory->listUserInterfaces());
+                                cerr << "Cannot find default user interface: 
X, available user interfaces are:\n";
+                                printList(cerr, 
factory->listUserInterfaces());
         Thread::exitAll(1);
       }
       ui->startup();
@@ -453,7 +455,7 @@
       rtrt->setScene(createDefaultScene());
     }
 
-    
+
     
///////////////////////////////////////////////////////////////////////////
     // Configure the rendering stack from a specified file.
     if (stack_file.size()) {
@@ -490,17 +492,17 @@
     
///////////////////////////////////////////////////////////////////////////
     
///////////////////////////////////////////////////////////////////////////
     
///////////////////////////////////////////////////////////////////////////
-    
+
   } catch (SCIRun::Exception& e) {
     cerr << "manta.cc (top level): Caught SCIRun exception: " << e.message() 
<< '\n';
     Thread::exitAll( 1 );
-               
+
   } catch (std::exception e){
     cerr << "manta.cc (top level): Caught std exception: "
          << e.what()
          << '\n';
     Thread::exitAll(1);
-               
+
   } catch(...){
     cerr << "manta.cc (top level): Caught unknown exception\n";
     Thread::exitAll(1);
@@ -517,16 +519,16 @@
 
 void make_stack( ReadContext &context, const vector<string> &args ) {
   // Defaults.
-  
+
   if(!factory->selectLoadBalancer("workqueue"))
     throw InternalError("default load balancer not found", __FILE__, 
__LINE__);
-  
+
   if(!factory->selectImageTraverser("tiled"))
     throw InternalError("default image traverser not found", __FILE__, 
__LINE__ );
-  
+
   if(!factory->selectPixelSampler("singlesample"))
     throw InternalError("default pixel sampler not found", __FILE__, 
__LINE__ );
-  
+
   if(!factory->selectRenderer("raytracer"))
     throw InternalError("default renderer not found", __FILE__, __LINE__ );
 
@@ -595,7 +597,7 @@
 
   Material* red=new Phong(Color(RGBColor(.6,0,0)),
                           Color(RGBColor(.6,.6,.6)), 32, 
(ColorComponent)0.4);
-       
+
   Material* plane_matl = new Phong(new 
CheckerTexture<Color>(Color(RGBColor(.6,.6,.6)),
                                                              
Color(RGBColor(0,0,0)),
                                                              Vector(1,0,0),
@@ -607,8 +609,8 @@
                                     (ColorComponent)0.5,
                                     Vector(1,0,0),
                                     Vector(0,1,0)));
-       
-       
+
+
   Group* world = new Group();
   Primitive* floor = new Parallelogram(plane_matl, Vector(-20,-20,0),
                                        Vector(40,0,0), Vector(0,40,0));
@@ -616,9 +618,10 @@
   UniformMapper* uniformmap = new UniformMapper();
   floor->setTexCoordMapper(uniformmap);
   world->add(floor);
-  world->add(new Sphere(red, Vector(0,0,1.2), 1.0));
+  //world->add(new Sphere(red, Vector(0,0,1.2), 1.0));
+  world->add(new superellipsoid(red, Vector(0,0,1.2), 1.0, 1.0, 1.0));
   scene->setObject(world);
-       
+
   LightSet* lights = new LightSet();
   lights->add(new PointLight(Vector(0,5,8), Color(RGBColor(.6,.1,.1))));
   lights->add(new PointLight(Vector(5,0,8), Color(RGBColor(.1,.6,.1))));




  • [MANTA] r1414 - in trunk: Core/Math Interface Model/Primitives StandAlone, boulos, 06/11/2007

Archive powered by MHonArc 2.6.16.

Top of page