Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2334 - in branches/depthbuffer: Engine/Display Engine/Factory Engine/PixelSamplers Image Interface


Chronological Thread 
  • From: "Li-Ta " Ollie " Lo" < >
  • To:
  • Subject: [Manta] r2334 - in branches/depthbuffer: Engine/Display Engine/Factory Engine/PixelSamplers Image Interface
  • Date: Tue, 30 Sep 2008 10:01:44 -0600 (MDT)

Author: ollie
Date: Tue Sep 30 10:01:34 2008
New Revision: 2334

Modified:
   branches/depthbuffer/Engine/Display/PureOpenGLDisplay.cc
   branches/depthbuffer/Engine/Factory/RegisterKnownComponents.cc
   branches/depthbuffer/Engine/PixelSamplers/SingleSampler.cc
   branches/depthbuffer/Image/Pixel.h
   branches/depthbuffer/Image/SimpleImage.h
   branches/depthbuffer/Image/SimpleImage_special.cc
   branches/depthbuffer/Interface/Fragment.h
Log:
added depth value support

Modified: branches/depthbuffer/Engine/Display/PureOpenGLDisplay.cc
==============================================================================
--- branches/depthbuffer/Engine/Display/PureOpenGLDisplay.cc    (original)
+++ branches/depthbuffer/Engine/Display/PureOpenGLDisplay.cc    Tue Sep 30 
10:01:34 2008
@@ -423,6 +423,9 @@
   } else if(typeid(*image) == typeid(SimpleImage<RGBAfloatPixel>)){
     format = GL_RGBA;
     type = GL_FLOAT;
+  } else if(typeid(*image) == typeid(SimpleImage<RGBZfloatPixel>)){
+      format = GL_RGBA;
+      type = GL_FLOAT;
   } else if(typeid(*image) == typeid(SimpleImage<RGBfloatPixel>)){
     format = GL_RGB;
     type = GL_FLOAT;
@@ -746,6 +749,9 @@
   } else if(typeid(*image) == typeid(SimpleImage<RGBAfloatPixel>)){
     format = GL_RGBA;
     type = GL_FLOAT;
+  } else if(typeid(*image) == typeid(SimpleImage<RGBZfloatPixel>)){
+      format = GL_RGBA;
+      type = GL_FLOAT;
   } else if(typeid(*image) == typeid(SimpleImage<RGBfloatPixel>)){
     format = GL_RGB;
     type = GL_FLOAT;

Modified: branches/depthbuffer/Engine/Factory/RegisterKnownComponents.cc
==============================================================================
--- branches/depthbuffer/Engine/Factory/RegisterKnownComponents.cc      
(original)
+++ branches/depthbuffer/Engine/Factory/RegisterKnownComponents.cc      Tue 
Sep 30 10:01:34 2008
@@ -111,6 +111,7 @@
     engine->registerComponent("bgra8", &SimpleImage<BGRA8Pixel>::create);
     engine->registerComponent("rgbafloat", 
&SimpleImage<RGBAfloatPixel>::create);
     engine->registerComponent("rgbfloat", 
&SimpleImage<RGBfloatPixel>::create);
+    engine->registerComponent("rgbzfloat", 
&SimpleImage<RGBZfloatPixel>::create);
 
     // Register load balancers
     engine->registerComponent("cyclic", &CyclicLoadBalancer::create);

Modified: branches/depthbuffer/Engine/PixelSamplers/SingleSampler.cc
==============================================================================
--- branches/depthbuffer/Engine/PixelSamplers/SingleSampler.cc  (original)
+++ branches/depthbuffer/Engine/PixelSamplers/SingleSampler.cc  Tue Sep 30 
10:01:34 2008
@@ -176,6 +176,7 @@
       _mm_store_ps(&fragment.color[0][f+i], 
_mm_load_ps(&raydata.color[0][i]));
       _mm_store_ps(&fragment.color[1][f+i], 
_mm_load_ps(&raydata.color[1][i]));
       _mm_store_ps(&fragment.color[2][f+i], 
_mm_load_ps(&raydata.color[2][i]));
+      _mm_store_ps(&fragment.depth[f+i], _mm_load_ps(&raydata.minT[i]));
     }
 #else
     int e = 0;
@@ -183,6 +184,7 @@
     for(int i=e;i<size;i++) {
       for ( int c = 0; c < Color::NumComponents; c++ )
         fragment.color[c][f+i] = raydata.color[c][i];
+      fragment.depth[f+i] = raydata.minT[i];
     }
   }
 }

Modified: branches/depthbuffer/Image/Pixel.h
==============================================================================
--- branches/depthbuffer/Image/Pixel.h  (original)
+++ branches/depthbuffer/Image/Pixel.h  Tue Sep 30 10:01:34 2008
@@ -241,6 +241,28 @@
     c.setG(p.g);
     c.setB(p.b);
   }
+
+  class RGBZfloatPixel {
+  public:
+    float r;
+    float g;
+    float b;
+    float z;
+  };
+
+  inline void convertToPixel(RGBZfloatPixel& p, const RGBColor& c, Real z){
+    p.r = c.r();
+    p.g = c.g();
+    p.b = c.b();
+    p.z = z;
+  }
+
+  inline void convertToRGBColor(RGBColor& c, const RGBZfloatPixel& p) {
+    c.setR(p.r);
+    c.setG(p.g);
+    c.setB(p.b);
+  }
+
 }
 
 #endif

Modified: branches/depthbuffer/Image/SimpleImage.h
==============================================================================
--- branches/depthbuffer/Image/SimpleImage.h    (original)
+++ branches/depthbuffer/Image/SimpleImage.h    Tue Sep 30 10:01:34 2008
@@ -134,7 +134,9 @@
       }
     }
   }
-  
+  template<>
+  void SimpleImage<RGBZfloatPixel>::splat(const Fragment& fragment);
+
   template<class Pixel>
   void SimpleImage<Pixel>::set(const Fragment& fragment)
   {
@@ -164,6 +166,9 @@
   template<>
     void SimpleImage<RGBAfloatPixel>::set(const Fragment& fragment);
 
+  template<>
+    void SimpleImage<RGBZfloatPixel>::set(const Fragment& fragment);
+
   template<class Pixel>
   void SimpleImage<Pixel>::get(Fragment& fragment) const
   {
@@ -191,13 +196,13 @@
   {
     *(eyeStart[eye][y]+x) = pixel;
   }
-  
+
   template<class Pixel>
   Pixel SimpleImage<Pixel>::get(int x, int y, int eye) const
   {
     return *(eyeStart[eye][y]+x);
   }
-  
+
   template<class Pixel>
     Pixel* SimpleImage<Pixel>::getRawPixels(int which_eye) const
   {

Modified: branches/depthbuffer/Image/SimpleImage_special.cc
==============================================================================
--- branches/depthbuffer/Image/SimpleImage_special.cc   (original)
+++ branches/depthbuffer/Image/SimpleImage_special.cc   Tue Sep 30 10:01:34 
2008
@@ -338,3 +338,44 @@
   }
 }
 
+template<>
+void SimpleImage<RGBZfloatPixel>::splat(const Fragment& fragment)
+{
+    // NOTE(boulos): This branch tries to copy fragments where a
+    // single sample splats onto several pixels
+    for (int i = fragment.begin(); i < fragment.end(); i++) {
+       RGBZfloatPixel pix;
+       convertToPixel(pix, fragment.getColor(i).convertRGB(), 
fragment.getDepth(i));
+
+       // start splatting
+       int y_index = fragment.getY(i);
+       int last_x = std::min(xres - fragment.getX(i), fragment.xPixelSize);
+       for (int y = 0; y < fragment.yPixelSize; y++) {
+           if (y_index >= yres)
+               break;
+
+           RGBZfloatPixel* row = eyeStart[fragment.getWhichEye(i)][y_index];
+           for (int x = 0; x < last_x; x++)
+               y_index++;
+       }
+    }
+}
+
+template<>
+void SimpleImage<RGBZfloatPixel>::set(const Fragment& fragment)
+{
+    if (fragment.xPixelSize != 1 || fragment.yPixelSize != 1) {
+       splat(fragment);
+    } else if (fragment.getFlag(Fragment::ConsecutiveX | 
Fragment::ConstantEye)) {
+       int b = fragment.begin();
+       RGBZfloatPixel* pix = 
eyeStart[fragment.getWhichEye(b)][fragment.getY(b)]+ fragment.getX(b);
+       for (int i = fragment.begin(); i < fragment.end(); i++)
+           convertToPixel(*pix++, fragment.getColor(i).convertRGB(), 
fragment.getDepth(i));
+    } else {
+       for (int i = fragment.begin(); i < fragment.end(); i++) {
+           
convertToPixel(eyeStart[fragment.getWhichEye(i)][fragment.getY(i)][fragment.getX(i)],
+                          fragment.getColor(i).convertRGB(), 
fragment.getDepth(i));
+       }
+    }
+}
+

Modified: branches/depthbuffer/Interface/Fragment.h
==============================================================================
--- branches/depthbuffer/Interface/Fragment.h   (original)
+++ branches/depthbuffer/Interface/Fragment.h   Tue Sep 30 10:01:34 2008
@@ -4,7 +4,7 @@
 #define Manta_Interface_Fragment_h
 
 /*
- *  Fragment.h: 
+ *  Fragment.h:
  *
  *  Written by:
  *   Author: Steve Parker
@@ -44,7 +44,7 @@
     };
 
     
///////////////////////////////////////////////////////////////////////////
-    // Empty Constructor    
+    // Empty Constructor
     Fragment(FragmentShape shape)
       : shape(shape), flags(0), pixelBegin(0), pixelEnd(0)
       {
@@ -61,7 +61,7 @@
     {
       setConsecutiveX(xstart, xend, y, eye);
     }
-       
+
     ~Fragment() {}
 
     void addElement(int x, int y, int eye) {
@@ -71,7 +71,7 @@
       whichEye[pixelEnd] = eye;
       pixelEnd++;
     }
-      
+
     void setElement( int i, int x, int y, int eye ) {
       ASSERTRANGE(i, 0, MaxSize);
       pixel[0][i] = x;
@@ -92,7 +92,7 @@
       pixelBegin = 0;
       pixelEnd = nx;
     }
-    
+
     void resetSize() {
       pixelBegin = 0;
       pixelEnd = 0;
@@ -211,6 +211,15 @@
         color[i][which] += add[i];
     }
 
+    void setDepth(int which, const Real z)
+    {
+       depth[which] = z;
+    }
+    Real getDepth(int which) const
+    {
+       return depth[which];
+    }
+
     void setPixelSize(int xps, int yps)
     {
       xPixelSize = xps;
@@ -219,7 +228,7 @@
 
     
///////////////////////////////////////////////////////////////////////////
     // Fragment Element Structure.
-    
+
     // Constant number of Elements so that we do not have to
     // dynamically allocate them.
     static const int MaxSize = FRAGMENT_MAXSIZE;
@@ -227,6 +236,7 @@
   public:
     // Fragment data
     MANTA_ALIGN(16) Color::ComponentType 
color[Manta::Color::NumComponents][MaxSize];
+    MANTA_ALIGN(16) Real depth[MaxSize];
     MANTA_ALIGN(16) int pixel[2][MaxSize];
     MANTA_ALIGN(16) int whichEye[MaxSize];
 


  • [Manta] r2334 - in branches/depthbuffer: Engine/Display Engine/Factory Engine/PixelSamplers Image Interface, Li-Ta , 09/30/2008

Archive powered by MHonArc 2.6.16.

Top of page