Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1134 - in trunk: Model/Intersections Model/Primitives scenes


Chronological Thread 
  • From: knolla@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1134 - in trunk: Model/Intersections Model/Primitives scenes
  • Date: Sun, 2 Jul 2006 16:48:14 -0600 (MDT)

Author: knolla
Date: Sun Jul  2 16:48:13 2006
New Revision: 1134

Modified:
   trunk/Model/Intersections/IsosurfaceImplicit.cc
   trunk/Model/Intersections/IsosurfaceImplicit.h
   trunk/Model/Primitives/IsosurfaceGridVolume.cc
   trunk/Model/Primitives/IsosurfaceOctreeVolume.cc
   trunk/scenes/gridisovol.cc
   trunk/scenes/octisovol.cc
Log:
Implemented Neubauer intersection for single-rayisosurfacing; more stable and 
faster results. Also fixed default lighting for octree and grid isovolume 
scenes.

Modified: trunk/Model/Intersections/IsosurfaceImplicit.cc
==============================================================================
--- trunk/Model/Intersections/IsosurfaceImplicit.cc     (original)
+++ trunk/Model/Intersections/IsosurfaceImplicit.cc     Sun Jul  2 16:48:13 
2006
@@ -6,8 +6,10 @@
 using namespace Manta;
 using namespace std;
 
+#define NEUBAUER_ITERATIONS 3
+
 //From Steven Parker's 1997 RTRT isosurface intersection
-bool IsosurfaceImplicit::single_intersect(const Vector& orig, const Vector& 
dir, 
+bool IsosurfaceImplicit::single_intersect_schwarze(const Vector& orig, const 
Vector& dir, 
                       const Vector& pmin, const Vector& pmax, float 
rho[2][2][2], 
                       float iso, float tmin, float tmax, float& t)
 {
@@ -71,6 +73,55 @@
 
 }
 
+
+bool IsosurfaceImplicit::single_intersect_neubauer(const Vector& orig, const 
Vector& dir, 
+                      const Vector& pmin, const Vector& pmax, float 
rho[2][2][2], 
+                      float iso, float tenter, float texit, float& hit_t)
+{
+        const Vector p0 = (orig + dir*tenter) - pmin;
+        const Vector p1 = (orig + dir*texit) - pmin;
+
+        CubicPoly poly;
+        poly.generate(p0, p1, rho, iso);
+        
+        float t0 = 0.f;
+        float t1 = 1.f;
+        float D0 = poly.d;
+        float D1 = poly.a+poly.b+poly.c+poly.d;
+        
+        if (D0 * D1 >= 0)
+            return false;
+
+        #pragma unroll(NEUBAUER_ITERATIONS)
+        for (int i=0;i<NEUBAUER_ITERATIONS;i++)
+        {
+            //compute linear interpolation
+            const float denom = 1./(D0 - D1);
+            float t = t0 + D0*denom*(t1-t0);
+
+            //re-evaluate
+            float D = poly.eval(t);
+    
+            if (D0*D < 0)
+            {
+                t1 = t;
+                D1 = D;
+            }
+            else
+            {
+                t0 = t;
+                D0 = D;
+            }
+        }
+        
+        const float denom = 1./(D0-D1);
+        const float t = t0 + D0*denom*(t1-t0);
+        hit_t = tenter + t*(texit-tenter);
+        
+        return (hit_t < texit);
+}
+
+
 //From Steven Parker's 1997 RTRT isosurface intersection
 void IsosurfaceImplicit::single_normal(Vector& outNormal, const Vector& 
pmin, const Vector& pmax, const Vector& p, float rho[2][2][2])
 {
@@ -165,7 +216,6 @@
         if (int_thisvoxelmask == 0)    //if none of them hit, don't bother 
iterating any more
             continue;
 
-        #define NEUBAUER_ITERATIONS 3                    
         #pragma unroll(NEUBAUER_ITERATIONS)
         for (int i=0;i<NEUBAUER_ITERATIONS;i++)
         {

Modified: trunk/Model/Intersections/IsosurfaceImplicit.h
==============================================================================
--- trunk/Model/Intersections/IsosurfaceImplicit.h      (original)
+++ trunk/Model/Intersections/IsosurfaceImplicit.h      Sun Jul  2 16:48:13 
2006
@@ -17,14 +17,111 @@
 {
     struct IsosurfaceImplicit
     {
-        static bool single_intersect(const Vector& orig, const Vector& dir, 
+    
+        static bool single_intersect_schwarze(const Vector& orig, const 
Vector& dir, 
                       const Vector& pmin, const Vector& pmax, float 
rho[2][2][2], 
                       float iso, float tmin, float tmax, float& t);
                       
+        static bool single_intersect_neubauer(const Vector& orig, const 
Vector& dir, 
+              const Vector& pmin, const Vector& pmax, float rho[2][2][2], 
+              float iso, float tenter, float texit, float& hit_t);
+                                
         static void single_normal(Vector& outNormal, const Vector& pmin, 
                       const Vector& pmax, const Vector& p, float 
rho[2][2][2]);
                       
+                                            
         //TODO - non-SSE packet intersection              
+        
+        //From Marmitt, Wald et al. 04 - for Neubauer intersection
+        struct CubicPoly
+        {
+            float a,b,c,d;
+            
+            void generate(const Vector& p0,
+                          const Vector& p1,
+                          const float voxel[2][2][2], 
+                          const float isovalue)
+            {
+                const Vector e0 = Vector(1,1,1) - p0;
+                const Vector e1 = p0;
+                const Vector d1 = p1 - p0;
+                float interimROO = d1[1] * d1[2];
+                
+                const float interimRRR = d1[0] * interimROO;
+                const float interimNRR = e1[0] * interimROO;
+                const float interimORR = e0[0] * interimROO;
+                interimROO = e1[1] * d1[2];
+                const float interimRNR = d1[0] * interimROO;
+                const float interimNNR = e1[0] * interimROO;
+                const float interimONR = e0[0] * interimROO;
+                interimROO = d1[1] * e1[2];
+                const float interimRRN = d1[0] * interimROO;
+                const float interimNRN = e1[0] * interimROO;
+                const float interimORN = e0[0] * interimROO;
+                interimROO = d1[1] * e0[2];
+                const float interimRRO = d1[0] * interimROO;
+                const float interimNRO = e1[0] * interimROO;
+                const float interimORO = e0[0] * interimROO;
+                interimROO = e0[1] * d1[2];
+                const float interimROR = d1[0] * interimROO;
+                const float interimNOR = e1[0] * interimROO;
+                const float interimOOR = e0[0] * interimROO;
+                interimROO = d1[0] * e1[1];
+                const float interimRNN = interimROO * e1[2];
+                const float interimRNO = interimROO * e0[2];
+                interimROO = d1[0] * e0[1];
+                const float interimRON = interimROO * e1[2];
+                interimROO = interimROO * e0[2];
+                
+                a
+                = interimRRR * (  voxel[1][1][1]
+                   - voxel[1][1][0]
+                   - voxel[1][0][1]
+                   + voxel[1][0][0]
+                   - voxel[0][1][1]
+                   + voxel[0][1][0]
+                   + voxel[0][0][1]
+                   - voxel[0][0][0]);
+                b
+                = voxel[1][1][1] * (interimNRR + interimRNR + interimRRN)
+                - voxel[1][1][0] * (interimNRR + interimRNR - interimRRO)
+                - voxel[1][0][1] * (interimNRR - interimROR + interimRRN)
+                + voxel[1][0][0] * (interimNRR - interimROR - interimRRO)
+                + voxel[0][1][1] * (interimORR - interimRNR - interimRRN)
+                - voxel[0][1][0] * (interimORR - interimRNR + interimRRO)
+                - voxel[0][0][1] * (interimORR + interimROR - interimRRN)
+                + voxel[0][0][0] * (interimORR + interimROR + interimRRO);
+                
+                c
+                = voxel[1][1][1] * (interimRNN + interimNRN + interimNNR)
+                + voxel[1][1][0] * (interimRNO + interimNRO - interimNNR)
+                + voxel[1][0][1] * (interimRON - interimNRN + interimNOR)
+                + voxel[1][0][0] * (interimROO - interimNRO - interimNOR)
+                + voxel[0][1][1] * (interimORN + interimONR - interimRNN)
+                - voxel[0][1][0] * (interimRNO - interimORO + interimONR)
+                - voxel[0][0][1] * (interimRON + interimORN - interimOOR)
+                - voxel[0][0][0] * (interimROO + interimORO + interimOOR);
+
+                d 
+                =
+                e1[0] * (e1[1] * (e1[2] * voxel[1][1][1] +
+                     e0[2] * voxel[1][1][0]) +
+                 e0[1] * (e1[2] * voxel[1][0][1] +
+                     e0[2] * voxel[1][0][0])) +
+                e0[0] * (e1[1] * (e1[2] * voxel[0][1][1] +
+                     e0[2] * voxel[0][1][0]) +
+                 e0[1] * (e1[2] * voxel[0][0][1] +
+                     e0[2] * voxel[0][0][0]));
+                     
+                 d -= isovalue;
+            }
+            
+            inline float eval(const float t) const
+            {
+                return ((((a)*t+b)*t+c)*t+d);
+            }
+        };
+        
                       
 #ifdef MANTA_SSE
         static void sse_intersect(SSERayPacket& srp, 
@@ -35,7 +132,7 @@
         static void sse_normal(SSERayPacket& srp, int smd, 
                     sse_t normal[], const Vector& pmin, const Vector& pmax,
                     const float rho[2][2][2]);
-                    
+                                    
         struct CubicPoly4
         {
             MANTA_ALIGN(16) sse_t a, b, c, d;          

Modified: trunk/Model/Primitives/IsosurfaceGridVolume.cc
==============================================================================
--- trunk/Model/Primitives/IsosurfaceGridVolume.cc      (original)
+++ trunk/Model/Primitives/IsosurfaceGridVolume.cc      Sun Jul  2 16:48:13 
2006
@@ -457,7 +457,7 @@
                     rho[1][1][0]=rhos[6];
                     rho[1][1][1]=rhos[7];
                     
-                    if (IsosurfaceImplicit::single_intersect(orig, dir, p0, 
p1, rho, 
+                    if (IsosurfaceImplicit::single_intersect_neubauer(orig, 
dir, p0, p1, rho, 
                         isoval, t, tmax, hit_t))
                     {
                         if (rays.hit(which_one, hit_t, 
PrimitiveCommon::getMaterial(), this, 0)) 

Modified: trunk/Model/Primitives/IsosurfaceOctreeVolume.cc
==============================================================================
--- trunk/Model/Primitives/IsosurfaceOctreeVolume.cc    (original)
+++ trunk/Model/Primitives/IsosurfaceOctreeVolume.cc    Sun Jul  2 16:48:13 
2006
@@ -557,7 +557,7 @@
                 if (octdata->get_isovalue() >= min_rho && 
octdata->get_isovalue() <= max_rho)
                 {
                     float hit_t;
-                    if (IsosurfaceImplicit::single_intersect(orig, dir, 
cmin, cmax, rho, 
+                    if (IsosurfaceImplicit::single_intersect_neubauer(orig, 
dir, cmin, cmax, rho, 
                         octdata->get_isovalue(), child_tenter, child_texit, 
hit_t))
                     {
                         if (rays.hit(which_one, hit_t, 
PrimitiveCommon::getMaterial(), this, 0)) 
@@ -709,7 +709,7 @@
         if (octdata->get_isovalue() >= min_rho && octdata->get_isovalue() <= 
max_rho)
         {
             float hit_t;
-            if (IsosurfaceImplicit::single_intersect(orig, dir, cmin, cmax, 
rho, 
+            if (IsosurfaceImplicit::single_intersect_neubauer(orig, dir, 
cmin, cmax, rho, 
                 octdata->get_isovalue(), child_tenter, child_texit, hit_t))
             {
                 if (rays.hit(which_one, hit_t, 
PrimitiveCommon::getMaterial(), this, 0)) 

Modified: trunk/scenes/gridisovol.cc
==============================================================================
--- trunk/scenes/gridisovol.cc  (original)
+++ trunk/scenes/gridisovol.cc  Sun Jul  2 16:48:13 2006
@@ -95,15 +95,16 @@
        PinholeCamera *camera = new PinholeCamera(eye, lookat, up, fov);
     //scene->setCamera(camera);
 
+    //NOTE: this will create a light directly "above" the volume in the +up 
direction.
+    //  Some volumes (e.g. heptane) will require us to change this to a -
        LightSet *lights = new LightSet();
-    lights->add( new PointLight(Vector(eye + 25.f*(up + Cross(eye-lookat, 
up))), Color(RGBColor(1,1,1))) );
+    lights->add( new PointLight( Vector(lookat + (10.f * lookat.length()) * 
up ), Color(RGBColor(1,1,1)) ) );
        lights->setAmbientLight( new ConstantAmbient( 
Color(RGBColor(0.4,0.5,0.5) ) ));
        scene->setLights(lights);
 
        
        // Background.
-    scene->setBackground( new ConstantBackground( Color(RGB(0.0, 0.0, 0.0)) 
) );
-       //scene->setBackground( new ConstantBackground( Color(RGB(0.99, 0.98, 
0.98)) ) );
+    scene->setBackground( new ConstantBackground( Color(RGB(.96, 0.96, 
0.97)) ) );
        
        return scene;
 }

Modified: trunk/scenes/octisovol.cc
==============================================================================
--- trunk/scenes/octisovol.cc   (original)
+++ trunk/scenes/octisovol.cc   Sun Jul  2 16:48:13 2006
@@ -152,14 +152,16 @@
        PinholeCamera *camera = new PinholeCamera(eye, lookat, up, fov);
     //scene->setCamera(camera);
 
+    //NOTE: this will create a light directly "above" the volume in the +up 
direction.
+    //  Some volumes (e.g. heptane) will require us to change this to a -
        LightSet *lights = new LightSet();
-    lights->add( new PointLight(Vector(eye + 25.f*(up + Cross(eye-lookat, 
up))), Color(RGBColor(1,1,1))) );
+    lights->add( new PointLight( Vector(lookat + (10.f * lookat.length()) * 
up ), Color(RGBColor(1,1,1)) ) );
        lights->setAmbientLight( new ConstantAmbient( 
Color(RGBColor(0.4,0.5,0.5) ) ));
        scene->setLights(lights);
 
        
        // Background.
-    scene->setBackground( new ConstantBackground( Color(RGB(0.0, 0.0, 0.0)) 
) );
+    scene->setBackground( new ConstantBackground( Color(RGB(.96, 0.96, 
0.97)) ) );
        
        return scene;
 }




  • [MANTA] r1134 - in trunk: Model/Intersections Model/Primitives scenes, knolla, 07/02/2006

Archive powered by MHonArc 2.6.16.

Top of page