Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r634 - in trunk: Model/Materials scenes


Chronological Thread 
  • From: aek@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r634 - in trunk: Model/Materials scenes
  • Date: Mon, 17 Oct 2005 12:19:36 -0600 (MDT)

Author: aek
Date: Mon Oct 17 12:19:35 2005
New Revision: 634

Added:
   trunk/Model/Materials/AmbientOcclusion.cc
      - copied unchanged from r578, 
branches/AFR/Model/Materials/AmbientOcclusion.cc
   trunk/Model/Materials/AmbientOcclusion.h
      - copied unchanged from r578, 
branches/AFR/Model/Materials/AmbientOcclusion.h
Modified:
   trunk/Model/Materials/CMakeLists.txt
   trunk/scenes/ParticleBVHTest.cc
Log:
A    Model/Materials/AmbientOcclusion.cc
A    Model/Materials/AmbientOcclusion.h
    - Brought over AmbientOcclusion shader from other branch

M    scenes/ParticleBVHTest.cc
    - Updated ParticleBVHTest to use AmbientOcclusion shader
    - ParticleBVHTest can now take manually provided min and
      max values for the colourmap, clamp colours to these



Modified: trunk/Model/Materials/CMakeLists.txt
==============================================================================
--- trunk/Model/Materials/CMakeLists.txt        (original)
+++ trunk/Model/Materials/CMakeLists.txt        Mon Oct 17 12:19:35 2005
@@ -9,4 +9,5 @@
      Materials/LitMaterial.cc
      Materials/MetalMaterial.cc
      Materials/Phong.cc
+     Materials/AmbientOcclusion.cc
      )

Modified: trunk/scenes/ParticleBVHTest.cc
==============================================================================
--- trunk/scenes/ParticleBVHTest.cc     (original)
+++ trunk/scenes/ParticleBVHTest.cc     Mon Oct 17 12:19:35 2005
@@ -11,7 +11,9 @@
 #include <Model/Backgrounds/LinearBackground.h>
 #include <Model/Lights/PointLight.h>
 #include <Model/Materials/Lambertian.h>
+#include <Model/Materials/AmbientOcclusion.h>
 #include <Model/Primitives/ParticleBVH.h>
+#include <Model/Textures/Constant.h>
 
 #include <Core/Math/MinMax.h>
 #include <sgi_stl_warnings_off.h>
@@ -48,6 +50,9 @@
   int map_channel = 0;
   double default_radius = 0.0005;
   Point light_position( 5.0, 5.0, 8.0 );
+  int occlusion_rays = 0;
+  double minimum_value = numeric_limits< double >::max();
+  double maximum_value = -numeric_limits< double >::max();
   int argc = static_cast< int >( args.size() );
   for ( int i = 0; i < argc; i++ ) {
     string arg = args[ i ];
@@ -60,42 +65,59 @@
     } else if ( arg == "-mapchannel" ) {
       if ( !getIntArg( i, args, map_channel ) )
         throw IllegalArgument( "scene particlebvhtest -mapchannel", i, args 
);
+    } else if ( arg == "-mapmin" ) {
+      if ( !getDoubleArg( i, args, minimum_value ) )
+        throw IllegalArgument( "scene particlebvhtest -mapmin", i, args );
+    } else if ( arg == "-mapmax" ) {
+      if ( !getDoubleArg( i, args, maximum_value ) )
+        throw IllegalArgument( "scene particlebvhtest -mapmax", i, args );
     } else if ( arg == "-radius" ) {
       if ( !getDoubleArg( i, args, default_radius ) )
         throw IllegalArgument( "scene particlebvhtest -radius", i, args );
     } else if ( arg == "-lightpos" ) {
       if ( !getPointArg( i, args, light_position ) )
         throw IllegalArgument( "scene particlebvhtest -lightpos", i, args );
+    } else if ( arg == "-occlusionrays" ) {
+      if ( !getIntArg( i, args, occlusion_rays ) )
+        throw IllegalArgument( "scene particlebvhtest -occlusionrays", i, 
args );
     } else {
       cerr << "Valid options for scene particlebvhtest:" << endl
            << " -model file - MPM particle set model to show" << endl
            << " -maxparticles number - Maximum number of particles to read 
and show" << endl
            << " -mapchannel number - Index of data field to use for color 
map" << endl
+           << " -mapmin number - Manually set lower bound on color map 
channel" << endl
+           << " -mapmax number - Manually set upper bound on color map 
channel" << endl
            << " -radius number - Default radius if none given in file" << 
endl
-           << " -lightpos point - Position of the light source" << endl;
+           << " -lightpos point - Position of the light source" << endl
+           << " -occlusionrays number - Use ambient occlusion with this many 
rays" << endl;
       throw IllegalArgument( "scene particlebvhtest", i, args );
     }
   }
-  ifstream in1( model_name.c_str() );
-  if ( !in1.is_open() )
-    throw IllegalArgument( "Couldn't load model: " + model_name, 0, args );
+  int limits_given = ( ( minimum_value != numeric_limits< double >::max() ) +
+                       ( maximum_value != -numeric_limits< double >::max() ) 
);
+  if ( limits_given == 1 )
+    throw IllegalArgument( "Need both mapmin and mapmax if either is 
given.", 0, args );
   int number_of_particles, number_of_variables, radius_index;
-  in1 >> number_of_particles >> number_of_variables >> radius_index;
-  if ( maximum_particles > 0 && number_of_particles > maximum_particles )
-      number_of_particles = maximum_particles;
   static const int maximum_number_of_variables = 32;
   double data[ maximum_number_of_variables ];
-  double minimum_value = numeric_limits< double >::max();
-  double maximum_value = -numeric_limits< double >::max();
-  if ( minimum_value == maximum_value )
+  if ( limits_given == 0 )
+  {
+    ifstream in1( model_name.c_str() );
+    if ( !in1.is_open() )
+      throw IllegalArgument( "Couldn't load model: " + model_name, 0, args );
+    in1 >> number_of_particles >> number_of_variables >> radius_index;
+    if ( maximum_particles > 0 && number_of_particles > maximum_particles )
+      number_of_particles = maximum_particles;
+    if ( minimum_value == maximum_value )
       maximum_value += 1.0;
-  for ( int particle = 0; particle < number_of_particles; ++particle ) {
-    for ( int variable = 0; variable < number_of_variables; ++variable )
-      in1 >> data[ variable ];
-    if ( data[ map_channel ] < minimum_value )
+    for ( int particle = 0; particle < number_of_particles; ++particle ) {
+      for ( int variable = 0; variable < number_of_variables; ++variable )
+        in1 >> data[ variable ];
+      if ( data[ map_channel ] < minimum_value )
         minimum_value = data[ map_channel ];
-    if ( data[ map_channel ] > maximum_value )
+      if ( data[ map_channel ] > maximum_value )
         maximum_value = data[ map_channel ];
+    }
   }
   ifstream in2( model_name.c_str() );
   if ( !in2.is_open() )
@@ -105,12 +127,18 @@
       number_of_particles = maximum_particles;
   ParticleBVH::ParticleTexture *texture = new ParticleBVH::ParticleTexture();
   Material *material = new Lambertian( texture );
+  if ( occlusion_rays > 0 )
+      material = new AmbientOcclusion( texture, new Constant<float>( 0.01 ), 
occlusion_rays );
   ParticleBVH *bvh = new ParticleBVH( material, number_of_particles );
   texture->setParticleBVH( bvh );
   for ( int particle = 0; particle < number_of_particles; ++particle ) {
     for ( int variable = 0; variable < number_of_variables; ++variable )
       in2 >> data[ variable ];
     double map_value = ( data[ map_channel ] - minimum_value ) / ( 
maximum_value - minimum_value ) * 11;
+    if ( map_value < 0.0 )
+      map_value = 0.0;
+    else if ( map_value > 10.9999 )
+      map_value = 10.9999;
     bvh->setParticle( particle,
                       Interpolate( color_map[ Floor( map_value ) ],
                                    color_map[ Ceil( map_value ) ],
@@ -119,7 +147,7 @@
                       radius_index > 0 ? data[ radius_index ] : 
default_radius );
   }
   Scene *scene = new Scene();
-  scene->setBackground( new LinearBackground( Color( RGB( 0.2, 0.4, 0.9 ) ),
+  scene->setBackground( new LinearBackground( Color( RGB( 0.02, 0.04, 0.09 ) 
),
                                               Color( RGB( 0.0, 0.0, 0.0 ) ),
                                               Vector( 0.0, 1.0, 0.0 ) ) );
   scene->setObject( bvh );




  • [MANTA] r634 - in trunk: Model/Materials scenes, aek, 10/17/2005

Archive powered by MHonArc 2.6.16.

Top of page