Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1232 - in trunk: Engine/Factory Model/Materials SwigInterface UserInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1232 - in trunk: Engine/Factory Model/Materials SwigInterface UserInterface
  • Date: Mon, 6 Nov 2006 15:32:38 -0700 (MST)

Author: bigler
Date: Mon Nov  6 15:32:37 2006
New Revision: 1232

Modified:
   trunk/Engine/Factory/RegisterKnownComponents.cc
   trunk/Model/Materials/Dielectric.cc
   trunk/Model/Materials/Phong.cc
   trunk/SwigInterface/runmanta.py
   trunk/UserInterface/XWindowUI.cc
Log:

Engine/Factory/RegisterKnownComponents.cc

  Added Orthogonal camera registration back.

Model/Materials/Dielectric.cc

  Fixed bug that made the images junk.  For total internally reflected
  rays, the importance was being set on the parent rays instead of the
  spawned rays.  This was likely a typo.
  
  Set the debug flag for spawned rays if the parent is debug.

Model/Materials/Phong.cc

  Use maskedStore macros.  This code still needs some profiling to see
  which version is fastest before I propagate code changes around.

  Don't print out the stack for debug rays.

SwigInterface/runmanta.py

  Added createProg4TestScene.

UserInterface/XWindowUI.cc

  Set RayPacket::ConstantEye for debug packets.  This is caught by an
  ASSERT in the Camera code.

  Print out the color of the debug rays.


Modified: trunk/Engine/Factory/RegisterKnownComponents.cc
==============================================================================
--- trunk/Engine/Factory/RegisterKnownComponents.cc     (original)
+++ trunk/Engine/Factory/RegisterKnownComponents.cc     Mon Nov  6 15:32:37 
2006
@@ -116,7 +116,7 @@
     // Register cameras
     //engine->registerComponent("environment", &EnvironmentCamera::create);
     engine->registerComponent("pinhole", &PinholeCamera::create);
-    //engine->registerComponent("orthogonal", &OrthogonalCamera::create);
+    engine->registerComponent("orthogonal", &OrthogonalCamera::create);
     //engine->registerComponent("fisheye", &FisheyeCamera::create);
 
     // Register shadow algorithms

Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Mon Nov  6 15:32:37 2006
@@ -82,6 +82,11 @@
   RayPacket refracted_rays(refracted_data, RayPacket::UnknownShape,
                            0, 0, rays.getDepth()+1, 
RayPacket::NormalizedDirections);
 
+  if (rays.getFlag(RayPacket::DebugPacket)) {
+    reflected_rays.setFlag(RayPacket::DebugPacket);
+    refracted_rays.setFlag(RayPacket::DebugPacket);
+  }
+
   Color results[RayPacket::MaxSize];
   Color refl_attenuation[RayPacket::MaxSize];
   Color refr_attenuation[RayPacket::MaxSize];
@@ -120,7 +125,7 @@
       // total internal reflection - no attenuation
       Color refl_importance = in_importance * beers_color;
       if(refl_importance.luminance() > cutoff){
-        rays.setImportance(num_refl, refl_importance);
+        reflected_rays.setImportance(num_refl, refl_importance);
         Vector refl_dir = rayD + 2*n_dot_v*normal;
         reflected_rays.setRay(num_refl, hitpos, refl_dir);
         refl_source[num_refl] = i;
@@ -172,10 +177,13 @@
     context.renderer->traceRays(context, refracted_rays);
 
   // compute their results
-  for (int i = 0; i < num_refl; i++)
+  for (int i = 0; i < num_refl; i++) {
     results[refl_source[i]] += refl_attenuation[i] * 
reflected_rays.getColor(i);
-  for (int i = 0; i < num_refr; i++)
+  }
+  for (int i = 0; i < num_refr; i++) {
     results[refr_source[i]] += refr_attenuation[i] * 
refracted_rays.getColor(i);
+  }
+
   for(int i = rays.begin(); i < rays.end(); i++)
     rays.setColor(i, results[i]);
 }

Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc      (original)
+++ trunk/Model/Materials/Phong.cc      Mon Nov  6 15:32:37 2006
@@ -50,16 +50,33 @@
 using namespace Manta;
 
 #define USE_MASKEDSTORE 1
-static inline void maskedStore(__m128i mask, __m128i* oldD, __m128i newD) {
+#define USE_INTMASKEDSTORE 0
+
+#if 0
+static inline void maskedStore_si128(__m128i mask, __m128i* oldD, __m128i 
newD)
+{
   _mm_store_si128(oldD,
                   _mm_or_si128(_mm_and_si128(mask, newD),
                                _mm_andnot_si128(mask, 
_mm_load_si128(oldD))));
 }
-static inline void maskedStore(__m128 mask, float* oldD, __m128 newD) {
+static inline void maskedStore_ps(__m128 mask, float* oldD, __m128 newD) {
   _mm_store_ps(oldD,
                _mm_or_ps(_mm_and_ps(mask, newD),
                          _mm_andnot_ps(mask, _mm_load_ps(oldD))));
 }
+#else
+
+#define maskedStore_si128(mask, oldD, newD)                         \
+  _mm_store_si128(oldD,                                             \
+                  _mm_or_si128(_mm_and_si128(mask, newD),           \
+                               _mm_andnot_si128(mask, _mm_load_si128(oldD))))
+
+#define maskedStore_ps(mask, oldD, newD)                            \
+  _mm_store_ps(oldD,                                                \
+               _mm_or_ps(_mm_and_ps(mask, newD),                    \
+                         _mm_andnot_ps(mask, _mm_load_ps(oldD))))
+
+#endif
 
 Phong::Phong(const Color& diffuse, const Color& specular,
              int specpow, ColorComponent refl)
@@ -100,7 +117,7 @@
 {
   if (rays.getFlag(RayPacket::DebugPacket)) {
     cerr << "Phong::shade called\n";
-    cerr << SCIRun::getStackTrace();
+    //    cerr << SCIRun::getStackTrace();
   }
   // Shade a bunch of rays.  We know that they all have the same intersected
   // object and are all of the same material
@@ -224,26 +241,26 @@
           _mm_store_ps(&ambientAndDiffuseLight[2][i], 
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]), _mm_mul_ps(lightb, 
cos_theta)));
         } else {
 #if USE_MASKEDSTORE
-#if 0
-          maskedStore(_mm_castps_si128(mask),
-                      (__m128i*)&ambientAndDiffuseLight[0][i],
-                      
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]), 
_mm_mul_ps(lightr, cos_theta))));
-          maskedStore(_mm_castps_si128(mask),
-                      (__m128i*)&ambientAndDiffuseLight[1][i],
-                      
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]), 
_mm_mul_ps(lightg, cos_theta))));
-          maskedStore(_mm_castps_si128(mask),
-                      (__m128i*)&ambientAndDiffuseLight[2][i],
-                      
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]), 
_mm_mul_ps(lightb, cos_theta))));
+#if USE_INTMASKEDSTORE
+          maskedStore_si128(_mm_castps_si128(mask),
+                            (__m128i*)&ambientAndDiffuseLight[0][i],
+                            
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]), 
_mm_mul_ps(lightr, cos_theta))));
+          maskedStore_si128(_mm_castps_si128(mask),
+                            (__m128i*)&ambientAndDiffuseLight[1][i],
+                            
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]), 
_mm_mul_ps(lightg, cos_theta))));
+          maskedStore_si128(_mm_castps_si128(mask),
+                            (__m128i*)&ambientAndDiffuseLight[2][i],
+                            
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]), 
_mm_mul_ps(lightb, cos_theta))));
 #else
-          maskedStore(mask,(float*)&ambientAndDiffuseLight[0][i],
-                      _mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]),
-                                 _mm_mul_ps(lightr, cos_theta)));
-          maskedStore(mask,(float*)&ambientAndDiffuseLight[1][i],
-                      _mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]),
-                                 _mm_mul_ps(lightg, cos_theta)));
-          maskedStore(mask,(float*)&ambientAndDiffuseLight[2][i],
-                      _mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]),
-                                 _mm_mul_ps(lightb, cos_theta)));
+          maskedStore_ps(mask,(float*)&ambientAndDiffuseLight[0][i],
+                         
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]),
+                                    _mm_mul_ps(lightr, cos_theta)));
+          maskedStore_ps(mask,(float*)&ambientAndDiffuseLight[1][i],
+                         
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]),
+                                    _mm_mul_ps(lightg, cos_theta)));
+          maskedStore_ps(mask,(float*)&ambientAndDiffuseLight[2][i],
+                         
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]),
+                                    _mm_mul_ps(lightb, cos_theta)));
 #endif
 #else // USE_MASKEDSTORE
           _mm_maskmoveu_si128((__m128i) 
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]), 
_mm_mul_ps(lightr, cos_theta))), (__m128i) _mm_castps_si128(mask), 
(char*)&ambientAndDiffuseLight[0][i]);
@@ -279,9 +296,33 @@
           _mm_store_ps(&specularLight[1][i], 
_mm_add_ps(_mm_load_ps(&specularLight[1][i]), _mm_mul_ps(lightg, scale)));
           _mm_store_ps(&specularLight[2][i], 
_mm_add_ps(_mm_load_ps(&specularLight[2][i]), _mm_mul_ps(lightb, scale)));
         } else {
+#if USE_MASKEDSTORE
+#if USE_INTMASKEDSTORE
+          maskedStore_si128(_mm_castps_si128(mask),
+                            (__m128i*)&specularLight[0][i],
+                            
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&specularLight[0][i]), 
_mm_mul_ps(lightr, scale))));
+          maskedStore_si128(_mm_castps_si128(mask),
+                            (__m128i*)&specularLight[1][i],
+                            
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&specularLight[1][i]), 
_mm_mul_ps(lightg, scale))));
+          maskedStore_si128(_mm_castps_si128(mask),
+                            (__m128i*)&specularLight[2][i],
+                            
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&specularLight[2][i]), 
_mm_mul_ps(lightb, scale))));
+#else // USE_INTMASKEDSTORE
+          maskedStore_ps(mask,(float*)&specularLight[0][i],
+                         _mm_add_ps(_mm_load_ps(&specularLight[0][i]),
+                                    _mm_mul_ps(lightr, scale)));
+          maskedStore_ps(mask,(float*)&specularLight[1][i],
+                         _mm_add_ps(_mm_load_ps(&specularLight[1][i]),
+                                    _mm_mul_ps(lightg, scale)));
+          maskedStore_ps(mask,(float*)&specularLight[2][i],
+                         _mm_add_ps(_mm_load_ps(&specularLight[2][i]),
+                                    _mm_mul_ps(lightb, scale)));
+#endif // USE_INTMASKEDSTORE
+#else // USE_MASKEDSTORE
           _mm_maskmoveu_si128((__m128i) 
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&specularLight[0][i]), 
_mm_mul_ps(lightr, scale))), (__m128i) _mm_castps_si128(mask), 
(char*)&specularLight[0][i]);
           _mm_maskmoveu_si128((__m128i) 
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&specularLight[1][i]), 
_mm_mul_ps(lightg, scale))), (__m128i) _mm_castps_si128(mask), 
(char*)&specularLight[1][i]);
           _mm_maskmoveu_si128((__m128i) 
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&specularLight[2][i]), 
_mm_mul_ps(lightb, scale))), (__m128i) _mm_castps_si128(mask), 
(char*)&specularLight[2][i]);
+#endif // USE_MASKEDSTORE
         }
       }
       for(;i<rays.rayEnd;i++){

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Mon Nov  6 15:32:37 2006
@@ -91,6 +91,70 @@
     #
     return scene
 
+def createProg4TestScene():
+    scene = manta_new(Scene())
+    scene.setBackground(manta_new(ConstantBackground(Color(RGBColor(0.5, 
0.8, 0.9)))))
+    #
+    # world will be added to the scene
+    world = manta_new(Group())
+    # Collection of objects that will be put in the BVH.
+    objs = Array1_ObjectP()
+    #
+    groundmatl = manta_new(Lambertian(Color(RGBColor(0.25, 0.95, 0.25))))
+    world.add(manta_new(Plane(groundmatl,
+                              Vector(0,0,1), Vector(0,0,2.5))))
+    #
+    lenscale = 2.5
+    glass = Color(RGBColor(pow(0.80, lenscale), pow(0.93, lenscale), 
pow(0.87, lenscale)))
+    for i in range(4):
+        eta = 1 + i*0.5 + .05
+        transp_matl = manta_new(Dielectric(eta, 1, glass))
+        corner = Vector(i*1.3 - 4, -3, 2.5+1.e-4)
+        size = Vector(0.20, 2.5, 1.4)
+        objs.add(manta_new(Cube(transp_matl, corner, corner+size)))
+        #
+    # Line of rings
+    ringmatl = manta_new(Lambertian(Color(RGBColor(.6, .6, .9))))
+    r = .30
+    inner_radius = r*0.5
+    center = Vector(-6, 0, 2.5+r)
+    offset = Vector(2.25*r, 0, 0)
+    for i in range(9):
+        objs.add(manta_new(Ring(ringmatl,
+                                center+offset*i,
+                                Vector(0.2, -1, -0.2),
+                                inner_radius, r-inner_radius)))
+    # Metal balls
+    ball_matl = manta_new(MetalMaterial(Color(RGBColor(0.8, 0.8, 0.8)), 100))
+    objs.add(manta_new(Sphere(ball_matl, Vector(-6, 3.5, 3.5), 1.0)))
+    objs.add(manta_new(Sphere(ball_matl, Vector(-7, 2.5, 2.5), 1.0)))
+    objs.add(manta_new(Sphere(ball_matl, Vector(-5, 4.5, 4.5), 1.0)))
+    #
+    # Blue balls
+    phongmatl = manta_new(Phong(Color(RGBColor(0.3, 0.3, 0.9)),
+                                Color(RGBColor(1,1,1)), 30))
+    for i in range(5):
+        objs.add(manta_new(Sphere(phongmatl, Vector(-4.5 + i, 3.5 + i/4., 3 
+ i/2.), 0.5)))
+    #
+    phongmatl2 = manta_new(Phong(Color(RGBColor(0.9, 0.3, 0.3)),
+                                 Color(RGBColor(1,1,1)), 30))
+    objs.add(manta_new(Cube(phongmatl2,
+                            Vector(-4.5, -4.5, 2),
+                            Vector(-8.5, -8.5, 8))))
+    # Create a BVH
+    world.add(manta_new(RealisticBvh(objs.get_objs(), objs.size())))
+    scene.setObject(world)
+    #
+    lights = manta_new(LightSet())
+    lights.add(manta_new(PointLight(Vector(20, 30, 100), 
Color(RGBColor(.9,.9,.9)))))
+    lights.add(manta_new(PointLight(Vector(-40, -30, 50), 
Color(RGBColor(.3,.1,.1)))))
+    lights.setAmbientLight(manta_new(ConstantAmbient(Color(RGBColor(.4, .4, 
.4)))))
+    #
+    scene.setLights(lights)
+    scene.getRenderParameters().maxDepth = 25
+    scene.getRenderParameters().importanceCutoff = 0.01
+    #
+    return scene
 
 def setupDefaultEngine(numworkers):
     print "Using " + str(numworkers) + " rendering threads."
@@ -133,13 +197,15 @@
 
 defaultCamera = factory.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 
0 0 1 -fov 60)")
 #defaultCamera = factory.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7 
2.5 2.5 -up 0 0 1 -fov 15)")
+#defaultCamera = factory.createCamera("pinhole(-eye 8.3 -18 7 -lookat -4.7 
2.5 3 -up 0 0 1 -fov 15)")
 
 addXInterface(engine, defaultCamera, 512, 512)
 #addNullInterface(engine, defaultCamera, 512, 512)
 
 # scene = createDefaultScene()
 scene = createDefaultScenePython()
-# scene = createDielectricTestScene()
+#scene = createDielectricTestScene()
+#scene = createProg4TestScene()
 engine.setScene(scene)
 
 

Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc    (original)
+++ trunk/UserInterface/XWindowUI.cc    Mon Nov  6 15:32:37 2006
@@ -1,5 +1,6 @@
 #include <UserInterface/XWindowUI.h>
 #include <Core/Util/Args.h>
+#include <Core/Color/ColorSpace_fancy.h>
 #include <Interface/Camera.h>
 #include <Interface/CameraPath.h>
 #include <Interface/Context.h>
@@ -763,7 +764,7 @@
   RayPacketData data;
   RayPacket rays( data, RayPacket::UnknownShape, 0, 1, 0, 0 );
 
-  rays.setFlag( RayPacket::DebugPacket );
+  rays.setFlag( RayPacket::DebugPacket | RayPacket::ConstantEye);
 
        // Shoot the ray.
        Color color;
@@ -772,6 +773,7 @@
   if (rays.wasHit(0)) {
     std::cerr << "t:       " << rays.getMinT(0) << "\n";
     std::cerr << "hit pos: " << rays.getHitPosition(0) << "\n";
+    std::cerr << "color  : " << rays.getColor(0).toString() << "\n";
   }
 }
 
@@ -795,7 +797,7 @@
   //  std::cerr << "Debug ray at ("<<image_x<<", "<<image_y<<")\n";
   std::cerr << "Debug sse ray at ("<<mouse_x<<", "<<mouse_y<<")\n";
 
-  rays.setFlag( RayPacket::DebugPacket );
+  rays.setFlag( RayPacket::DebugPacket | RayPacket::ConstantEye );
 
        // Shoot the ray.
        Color color;
@@ -805,6 +807,7 @@
     if (rays.wasHit(i)) {
       std::cerr << "t("<<i<<"):       " << rays.getMinT(i) << "\n";
       std::cerr << "hit pos("<<i<<"): " << rays.getHitPosition(i) << "\n";
+      std::cerr << "color  : "          << rays.getColor(i).toString() << 
"\n";
     }
   }
 }




  • [MANTA] r1232 - in trunk: Engine/Factory Model/Materials SwigInterface UserInterface, bigler, 11/06/2006

Archive powered by MHonArc 2.6.16.

Top of page