Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r833 - in trunk: . Core/Util Engine/Control Interface fox fox/disco_demo fox/disco_demo/Engine fox/disco_demo/Engine/ImageTraversers fox/disco_demo/Engine/Renderers fox/disco_demo/Engine/Shaders fox/disco_demo/Interface fox/disco_demo/StandAlone fox/dm_demo
- Date: Mon, 9 Jan 2006 04:15:19 -0700 (MST)
Author: abe
Date: Mon Jan 9 04:15:17 2006
New Revision: 833
Added:
trunk/fox/disco_demo/
trunk/fox/disco_demo/CMakeLists.txt
- copied, changed from r831, trunk/fox/dm_demo/CMakeLists.txt
trunk/fox/disco_demo/Engine/
trunk/fox/disco_demo/Engine/ImageTraversers/
trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc
trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h
trunk/fox/disco_demo/Engine/Renderers/
trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.h
trunk/fox/disco_demo/Engine/Shaders/
trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
trunk/fox/disco_demo/Engine/Shaders/AOShader.h
trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.cc
trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.h
trunk/fox/disco_demo/Interface/
trunk/fox/disco_demo/Interface/CMakeLists.txt
trunk/fox/disco_demo/Interface/DiscoTile.cc
trunk/fox/disco_demo/Interface/DiscoTile.h
trunk/fox/disco_demo/Interface/NeighborhoodShader.cc
trunk/fox/disco_demo/Interface/NeighborhoodShader.h
trunk/fox/disco_demo/Interface/PerSampleShader.cc
trunk/fox/disco_demo/Interface/PerSampleShader.h
trunk/fox/disco_demo/Interface/TilePacket.h
trunk/fox/disco_demo/StandAlone/
trunk/fox/disco_demo/StandAlone/CMakeLists.txt
trunk/fox/disco_demo/StandAlone/disco_demo.cc
Modified:
trunk/CMakeLists.txt
trunk/Core/Util/ThreadStorage.cc
trunk/Core/Util/ThreadStorage.h
trunk/Engine/Control/RTRT.cc
trunk/Engine/Control/RTRT.h
trunk/Interface/MantaInterface.h
trunk/Interface/Material.h
trunk/fox/CMakeLists.txt
trunk/fox/dm_demo/dm_demo.cc
Log:
Further tested interface. Added a dereference operator.
M Core/Util/ThreadStorage.cc
M Core/Util/ThreadStorage.h
Added initial implementation (still a bit broken, and quite slow) of "disco"
shaders.
Partial implementation of ambient occlusion shader, still needs quite a bit
of work. It should be possible to implement the IGI papers now in manta,
however there is probably a lot of performance tuning to do first.
A fox/disco_demo
A fox/disco_demo/Interface
A fox/disco_demo/Interface/NeighborhoodShader.cc
A fox/disco_demo/Interface/DiscoTile.cc
A fox/disco_demo/Interface/PerSampleShader.cc
A fox/disco_demo/Interface/NeighborhoodShader.h
A fox/disco_demo/Interface/DiscoTile.h
A fox/disco_demo/Interface/PerSampleShader.h
A fox/disco_demo/Interface/TilePacket.h
A fox/disco_demo/Interface/CMakeLists.txt
A fox/disco_demo/Engine
A fox/disco_demo/Engine/ImageTraversers
A fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc
A fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h
A fox/disco_demo/Engine/Renderers
A fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
A fox/disco_demo/Engine/Renderers/DiscoRayTracer.h
A fox/disco_demo/Engine/Shaders
A fox/disco_demo/Engine/Shaders/DepthMapShader.h
A fox/disco_demo/Engine/Shaders/AOShader.cc
A fox/disco_demo/Engine/Shaders/AOShader.h
A fox/disco_demo/Engine/Shaders/DepthMapShader.cc
A fox/disco_demo/StandAlone
A fox/disco_demo/StandAlone/disco_demo.cc
A fox/disco_demo/StandAlone/CMakeLists.txt
A fox/disco_demo/CMakeLists.txt
M fox/CMakeLists.txt
M fox/dm_demo/dm_demo.cc
Added Copyright message.
M Interface/Material.h
Added set methods for ImageTraverser and Renderer (in addition to select
methods already there).
M Interface/MantaInterface.h
M Engine/Control/RTRT.cc
M Engine/Control/RTRT.h
M CMakeLists.txt
Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Mon Jan 9 04:15:17 2006
@@ -171,6 +171,17 @@
tests
)
+SET(MANTA_TARGET_LINK_LIBRARIES
+ Manta_Engine
+ Manta_UserInterface
+ Manta_Model
+ Manta_Image
+ Manta_Interface
+ Manta_Core
+ Manta_Core_XUtils
+ SCIRun_Core
+ )
+
# Since SWIG support wasn't added to CMake until version 2.0, only do
# the check if we have a new enough version.
IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.9)
Modified: trunk/Core/Util/ThreadStorage.cc
==============================================================================
--- trunk/Core/Util/ThreadStorage.cc (original)
+++ trunk/Core/Util/ThreadStorage.cc Mon Jan 9 04:15:17 2006
@@ -28,7 +28,12 @@
#include <Core/Util/ThreadStorage.h>
+#include <Interface/Context.h>
+
using namespace Manta;
+
+ThreadStorage::Allocator::Allocator( const RenderContext &context, Token
token_ )
+ : storage( *context.storage_allocator ), proc( context.proc ), token(
token_ ) { }
ThreadStorage::ThreadStorage( int num_procs_ ) :
requested( 0 ),
Modified: trunk/Core/Util/ThreadStorage.h
==============================================================================
--- trunk/Core/Util/ThreadStorage.h (original)
+++ trunk/Core/Util/ThreadStorage.h Mon Jan 9 04:15:17 2006
@@ -1,3 +1,6 @@
+#ifndef Manta_Util_ThreadStorage__H
+#define Manta_Util_ThreadStorage__H
+
/*
For more information, please see:
http://software.sci.utah.edu
@@ -37,6 +40,8 @@
using SCIRun::InternalError;
using std::vector;
+
+ class RenderContext;
///////////////////////////////////////////////////////////////////////////
// Thread local storage allocation.
@@ -78,6 +83,7 @@
// initalize per thread storage.
class Allocator {
public:
+ Allocator( const RenderContext &context, Token token_ );
Allocator( ThreadStorage &storage_, int proc_, Token token_ )
: storage( storage_ ), proc( proc_ ), token( token_ ) { };
@@ -88,6 +94,8 @@
return storage.get( proc, token );
}
+
+ void *operator *() const { return storage.get( proc, token ); }
private:
ThreadStorage &storage;
@@ -131,4 +139,6 @@
};
};
+
+#endif
Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc (original)
+++ trunk/Engine/Control/RTRT.cc Mon Jan 9 04:15:17 2006
@@ -832,6 +832,11 @@
return list;
}
+void RTRT::setImageTraverser( ImageTraverser *image_traverser_ ) {
+
+ currentImageTraverser = image_traverser_;
+}
+
bool RTRT::selectImageTraverser(const string& spec)
{
string name;
@@ -940,6 +945,11 @@
iter != pixelSamplers.end(); iter++)
list.push_back(iter->first);
return list;
+}
+
+void RTRT::setRenderer( Renderer *renderer_ ) {
+
+ currentRenderer = renderer_;
}
bool RTRT::selectRenderer(const string& spec)
Modified: trunk/Engine/Control/RTRT.h
==============================================================================
--- trunk/Engine/Control/RTRT.h (original)
+++ trunk/Engine/Control/RTRT.h Mon Jan 9 04:15:17 2006
@@ -52,6 +52,7 @@
bool changePipeline);
// Image Traversers
+ virtual void setImageTraverser( ImageTraverser *image_traverser_ );
virtual bool selectImageTraverser(const string& spec);
virtual void registerComponent(const string& name, ImageTraverserCreator
creator);
virtual listType listImageTraversers() const;
@@ -73,6 +74,7 @@
virtual listType listPixelSamplers() const;
// Renderers
+ virtual void setRenderer( Renderer *renderer_ );
virtual bool selectRenderer(const string& spec);
virtual void registerComponent(const string& name, RendererCreator
creator);
virtual listType listRenderers() const;
Modified: trunk/Interface/MantaInterface.h
==============================================================================
--- trunk/Interface/MantaInterface.h (original)
+++ trunk/Interface/MantaInterface.h Mon Jan 9 04:15:17 2006
@@ -56,6 +56,7 @@
// Image Traversers
typedef ImageTraverser* (*ImageTraverserCreator)(const vector<string>&
args);
+ virtual void setImageTraverser( ImageTraverser *image_traverser_ ) = 0;
virtual bool selectImageTraverser(const string& spec) = 0;
virtual void registerComponent(const string& name, ImageTraverserCreator
creator) = 0;
virtual listType listImageTraversers() const = 0;
@@ -82,6 +83,7 @@
// Renderers
typedef Renderer* (*RendererCreator)(const vector<string>& args);
+ virtual void setRenderer( Renderer *renderer_ ) = 0;
virtual bool selectRenderer(const string& spec) = 0;
virtual void registerComponent(const string& name, RendererCreator
creator) = 0;
virtual listType listRenderers() const = 0;
Modified: trunk/Interface/Material.h
==============================================================================
--- trunk/Interface/Material.h (original)
+++ trunk/Interface/Material.h Mon Jan 9 04:15:17 2006
@@ -2,6 +2,34 @@
#ifndef Manta_Interface_Material_h
#define Manta_Interface_Material_h
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
#include <Core/Geometry/PointVector.h>
namespace Manta {
Modified: trunk/fox/CMakeLists.txt
==============================================================================
--- trunk/fox/CMakeLists.txt (original)
+++ trunk/fox/CMakeLists.txt Mon Jan 9 04:15:17 2006
@@ -15,6 +15,7 @@
# Demo examples.
SUBDIRS(
+ disco_demo
dm_demo
sc_demo
)
Copied: trunk/fox/disco_demo/CMakeLists.txt (from r831,
trunk/fox/dm_demo/CMakeLists.txt)
==============================================================================
--- trunk/fox/dm_demo/CMakeLists.txt (original)
+++ trunk/fox/disco_demo/CMakeLists.txt Mon Jan 9 04:15:17 2006
@@ -1,8 +1,43 @@
-
+SET(BUILD_DISCO_DEMO 0 CACHE BOOL "Build Disco Shader Demo")
+IF(BUILD_DISCO_DEMO)
##########################################################
- # Add the dm_demo program
- ADD_EXECUTABLE (dm_demo dm_demo.cc)
- TARGET_LINK_LIBRARIES(dm_demo FManta_static)
+ # Add the disc_demo dependent code.
+
+ SET(DISCO_SRC
+
+ # Engine
+ Engine/ImageTraversers/DiscoImageTraverser.cc
+ Engine/ImageTraversers/DiscoImageTraverser.h
+ Engine/Renderers/DiscoRayTracer.cc
+ Engine/Renderers/DiscoRayTracer.h
+ Engine/Shaders/DepthMapShader.cc
+ Engine/Shaders/DepthMapShader.h
+ Engine/Shaders/AOShader.cc
+ Engine/Shaders/AOShader.h
+
+ # Interface
+ Interface/DiscoTile.cc
+ Interface/DiscoTile.h
+ Interface/NeighborhoodShader.cc
+ Interface/NeighborhoodShader.h
+ Interface/PerSampleShader.cc
+ Interface/PerSampleShader.h
+ Interface/TilePacket.h
+
+ # Model
+ )
+
+ # Add a library with the code.
+ ADD_LIBRARY( disco_shared
+ ${DISCO_SRC}
+ )
+
+ TARGET_LINK_LIBRARIES( disco_shared
+ ${MANTA_TARGET_LINK_LIBRARIES}
+ )
+
+ SUBDIRS(StandAlone)
+ENDIF(BUILD_DISCO_DEMO)
\ No newline at end of file
Added: trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc Mon
Jan 9 04:15:17 2006
@@ -0,0 +1,263 @@
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h>
+
+#include <Core/Exceptions/IllegalArgument.h>
+#include <Core/Util/Args.h>
+#include <Interface/Context.h>
+#include <Interface/Fragment.h>
+#include <Interface/Image.h>
+#include <Interface/LoadBalancer.h>
+#include <Interface/PixelSampler.h>
+#include <Core/Thread/Mutex.h>
+#include <Core/Util/NotFinished.h>
+
+#include <SCIRun/Core/Util/Assert.h>
+
+#include <disco_demo/Interface/DiscoTile.h>
+#include <disco_demo/Interface/TilePacket.h>
+#include <disco_demo/Engine/Renderers/DiscoRayTracer.h>
+
+using namespace Manta;
+using namespace disco;
+
+DiscoImageTraverser::DiscoImageTraverser( int xtilesize_, int ytilesize_,
int overlap_,
+ DiscoRayTracer
*disco_renderer_,
+ NeighborhoodShader
*neighborhood_shader_ )
+:
+ xtilesize( xtilesize_ ),
+ ytilesize( ytilesize_ ),
+ overlap( overlap_ ),
+ disco_renderer( disco_renderer_ ),
+ neighborhood_shader( neighborhood_shader_ ) { }
+
+DiscoImageTraverser::~DiscoImageTraverser()
+{
+}
+
+void DiscoImageTraverser::setupBegin(SetupContext& context, int numChannels)
+{
+ context.loadBalancer->setupBegin(context, numChannels);
+}
+
+void DiscoImageTraverser::setupDisplayChannel(SetupContext& context)
+{
+
/////////////////////////////////////////////////////////////////////////////
+ // Setup the image traverser.
+
+ // Determine the resolution.
+ bool stereo;
+ int xres, yres;
+ context.getResolution(stereo, xres, yres);
+
+ // Determine how many tiles are needed.
+ xtiles = (xres + xtilesize-1)/xtilesize;
+ ytiles = (yres + ytilesize-1)/ytilesize;
+
+ // Request storage for persistent fragments.
+ storage_token = DiscoTile::requestStorage( *context.storage_allocator,
+ xtilesize,
+ ytilesize,
+ overlap );
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Setup the rest of the stack.
+
+ // Tell the load balancer how much work to assign.
+ int numAssignments = xtiles * ytiles;
+ context.loadBalancer->setupDisplayChannel(context, numAssignments);
+
+ // Set up the scale from -1 to 1
+ xscale = (Real)2/xres;
+ yscale = xscale;
+ xoffset = (-xres/(Real)2+(Real)0.5)*xscale; // Offset to pixel center
+ yoffset = (-yres/(Real)2+(Real)0.5)*yscale;
+
+ // Setup the renderer.
+ context.renderer->setupDisplayChannel(context);
+}
+
+void DiscoImageTraverser::setupFrame(const RenderContext& context)
+{
+
/////////////////////////////////////////////////////////////////////////////
+ // Setup the image traverser.
+ neighborhood_shader->setupFrame( context );
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Setup the rest of the stack.
+ context.loadBalancer->setupFrame(context);
+
+ // Setup the renderer.
+ context.renderer->setupFrame( context );
+}
+
+void DiscoImageTraverser::renderImage(const RenderContext& context, Image*
image)
+{
+
+ // Obtain a pointer to persistant storage and initialize it.
+ DiscoTile *disco_tile = new ( ThreadStorage::Allocator( context,
storage_token),
+ xtilesize,
+ ytilesize,
+ overlap ) DiscoTile;
+
+ // Determine resolution
+ bool stereo;
+ int xres, yres;
+ image->getResolution(stereo, xres, yres);
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Call the load balancer to get work assignments.
+ int kernel_width = overlap*2+1;
+
+ int s,e;
+ while(context.loadBalancer->getNextAssignment(context, s, e)){
+
+ for(int assignment = s; assignment < e; assignment++){
+
+
/////////////////////////////////////////////////////////////////////////
+ // Place pixels in the tile.
+
+ // Determine which tile.
+ int xtile = assignment/ytiles;
+ int ytile = assignment%ytiles;
+
+ // First pixel in the tile.
+ int xstart = xtile * xtilesize;
+ int ystart = ytile * ytilesize;
+
+ int xend = xstart+xtilesize;
+ int yend = ystart+ytilesize;
+
+ int xtile_end = (xend > xres) ? xres-xstart : xtilesize;
+ int ytile_end = (yend > yres) ? yres-ystart : ytilesize;
+
+
/////////////////////////////////////////////////////////////////////////
+ // Initialize ray packet elements.
+ int total_elements = 0;
+ for (int y=-1;y<=ytile_end;++y) {
+ for (int x=-1;x<=xtile_end;++x) {
+
+ RayPacket::Element &r = disco_tile->getRayPacketElement( x, y );
+ TilePacket::Element &t = disco_tile->getTilePacketElement( x, y );
+
+
/////////////////////////////////////////////////////////////////////
+ // Initialize the tile.
+ t.tilex = x;
+ t.tiley = y;
+ t.overlap =
+ (x<0 || x>=xtilesize) ||
+ (y<0 || y>=ytilesize);
+
+ t.task = (total_elements++)%kernel_width;
+
+
/////////////////////////////////////////////////////////////////////
+ // Initialize the ray packet element
+ r.imageX = (xstart + x) * xscale + xoffset;
+ r.imageY = (ystart + y) * yscale + yoffset;
+ r.whichEye = 0;
+ }
+ }
+
+
/////////////////////////////////////////////////////////////////////////
+ // Create ray packets from disco tile and render.
+ int flags = RayPacket::HaveImageCoordinates | RayPacket::ConstantEye;
+
+ int total_packets = (disco_tile->getTotalElements() /
RayPacket::MaxSize) +
+ ((disco_tile->getTotalElements() % RayPacket::MaxSize) != 0);
+
+ for (int i=0;i<total_packets; ++i) {
+
+ // Create a tile packet.
+ TilePacket packet( disco_tile->getRayPacketData( i ),
+ disco_tile->getTilePacketData( i ),
+ disco_tile->getPacketSize( i ),
+ 0,
+ flags );
+
+ // Render the packet.
+ disco_renderer->traceEyeRays( context, packet );
+ }
+
+
/////////////////////////////////////////////////////////////////////////
+ // Call the neighborhood shader and write image results.
+
+ Fragment fragment;
+
+ for (int i=0;i<total_packets; ++i) {
+
+ // Since we don't where the overlap is in the packets, the shader is
+ // called on all of the samples, including overlap.
+ // Create a tile packet.
+ TilePacket packet( disco_tile->getRayPacketData( i ),
+ disco_tile->getTilePacketData( i ),
+ disco_tile->getPacketSize( i ),
+ 0,
+ flags );
+
+
///////////////////////////////////////////////////////////////////////
+ // Shade the packet
+ neighborhood_shader->shade( context, disco_tile, packet );
+
+
///////////////////////////////////////////////////////////////////////
+ // Copy results to a fragment.
+ int fragment_size = 0;
+ for (int j=0;j<packet.getSize();++j) {
+
+ // Make sure the element isn't part of the overlap.
+ TilePacket::Element &t = packet.getTilePacketElement( j );
+ if (!t.overlap) {
+
+ Fragment::Element &f = fragment.get( fragment_size++ );
+ RayPacket::Element &r = packet.getRayPacketElement( j );
+
+ // Pixel coordinates.
+ f.which_eye = 0;
+ f.x = t.tilex + xstart;
+ f.y = t.tiley + ystart;
+
+ // Result
+ f.color = r.color;
+ }
+ }
+
+ fragment.setSize( fragment_size );
+
+
+ // Set image values.
+ image->set( fragment );
+ }
+ }
+ }
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Specify that the image is valid.
+ if(context.proc == 0)
+ image->setValid(true);
+}
Added: trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h Mon
Jan 9 04:15:17 2006
@@ -0,0 +1,114 @@
+#ifndef disco_DiscoImageTraverser__H
+#define disco_DiscoImageTraverser__H
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+// Abe Stephens, January 2006
+
+#include <MantaTypes.h>
+#include <Interface/ImageTraverser.h>
+#include <Core/Util/ThreadStorage.h>
+
+#include <disco_demo/Interface/NeighborhoodShader.h>
+#include <disco_demo/Interface/PerSampleShader.h>
+
+namespace Manta {
+ class SetupContext;
+ class RenderContext;
+ class Image;
+};
+
+namespace disco {
+
+ using namespace Manta;
+
+ class DiscoTile;
+ class DiscoRayTracer;
+ class NeighborhoodShader;
+
+ class DiscoImageTraverser : public ImageTraverser {
+ public:
+
+
///////////////////////////////////////////////////////////////////////////
+ // Constructors
+ DiscoImageTraverser( int xtilesize_, int ytilesize_, int overlap_,
+ DiscoRayTracer *disco_renderer_,
+ NeighborhoodShader *neighborhood_shader_ );
+
+ virtual ~DiscoImageTraverser();
+
+ // Image traverser interface.
+ virtual void setupBegin(SetupContext&, int numChannels);
+ virtual void setupDisplayChannel(SetupContext&);
+ virtual void setupFrame(const RenderContext& context);
+ virtual void renderImage(const RenderContext& context, Image* image);
+
+ // Accessors.
+ DiscoRayTracer *getDiscoRenderer() { return disco_renderer; };
+ NeighborhoodShader *getNeighborhoodShader() { return
neighborhood_shader; };
+
+ private:
+ DiscoImageTraverser(const DiscoImageTraverser&);
+ DiscoImageTraverser& operator=(const DiscoImageTraverser&);
+
+
///////////////////////////////////////////////////////////////////////////
+
+ // Renderer to invoke.
+ DiscoRayTracer *disco_renderer;
+
+ // Neighborhood shader.
+ NeighborhoodShader *neighborhood_shader;
+
+
///////////////////////////////////////////////////////////////////////////
+ // Image traverser members
+
+ // Thread local storage of tile.
+ ThreadStorage::Token storage_token;
+
+ // Size of tile
+ int xtilesize;
+ int ytilesize;
+ int overlap;
+
+ // Number of tiles.
+ int xtiles;
+ int ytiles;
+
+
///////////////////////////////////////////////////////////////////////////
+ // Sampler members.
+
+ Real xscale;
+ Real yscale;
+ Real xoffset;
+ Real yoffset;
+
+ };
+};
+
+#endif
Added: trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc Mon Jan 9
04:15:17 2006
@@ -0,0 +1,142 @@
+
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+
+#include <disco_demo/Engine/Renderers/DiscoRayTracer.h>
+#include <disco_demo/Interface/TilePacket.h>
+#include <disco_demo/Interface/PerSampleShader.h>
+
+#include <Interface/Background.h>
+#include <Interface/Camera.h>
+#include <Interface/Context.h>
+#include <Interface/Material.h>
+#include <Interface/Object.h>
+#include <Interface/RayPacket.h>
+#include <Interface/Scene.h>
+#include <Core/Util/Assert.h>
+
+using namespace Manta;
+using namespace disco;
+
+//////////////////////////////////////////////////////////////////////////////
+// Constructor
+
+DiscoRayTracer::DiscoRayTracer( PerSampleShader *per_sample_shader_ ) :
+ per_sample_shader( per_sample_shader_ )
+{
+}
+
+DiscoRayTracer::~DiscoRayTracer()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Renderer Interface.
+
+void DiscoRayTracer::setupBegin(const SetupContext&, int)
+{
+}
+
+void DiscoRayTracer::setupDisplayChannel(SetupContext& context) {
+
+ // Setup the shader.
+ per_sample_shader->setupDisplayChannel( context );
+}
+
+void DiscoRayTracer::setupFrame(const RenderContext& context ) {
+
+ // Setup the shader.
+ per_sample_shader->setupFrame( context );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+// TilePacket methods should be called by a DiscoImageTraverser instead!!
+
+void DiscoRayTracer::traceEyeRays(const RenderContext&, RayPacket& rays) {
+ ASSERT( false );
+}
+
+void DiscoRayTracer::traceRays(const RenderContext&, RayPacket& rays) {
+ ASSERT( false );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// Disco Renderer Methods.
+
+void DiscoRayTracer::traceEyeRays(const RenderContext& context, TilePacket&
tile_packet)
+{
+
+ ASSERT(tile_packet.getFlag(RayPacket::HaveImageCoordinates));
+
+ // Compute ray origin & direction using the camera.
+ context.camera->makeRays( tile_packet );
+ tile_packet.initializeImportance();
+
+ traceRays(context, tile_packet);
+}
+
+void DiscoRayTracer::traceRays(const RenderContext& context, TilePacket&
tile_packet)
+{
+
+ // Intersect the ray packet with the scene.
+ tile_packet.resetHit();
+ context.scene->getObject()->intersect(context, tile_packet);
+
+ // Find the first hit.
+ int start = 0;
+
+
+ for (;start<tile_packet.getSize();++start) {
+
+ while ((start<tile_packet.getSize()) &&
+ !tile_packet.hitInfo(start).wasHit())
+ ++start;
+
+ // Find a run of elements that generated hits.
+ int end = start;
+ while (end < tile_packet.getSize() && tile_packet.hitInfo(end).wasHit())
+ ++end;
+
+ // Create a sub packet of elements which generated hits.
+ TilePacket sub_packet( tile_packet, start, end );
+
+ // Send the packet to the disco per sample shader.
+ per_sample_shader->shade( context, sub_packet );
+
+ start = end;
+ };
+}
+
+
Added: trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.h Mon Jan 9
04:15:17 2006
@@ -0,0 +1,77 @@
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef disco_Engine_DiscoRaytracer_h
+#define disco_Engine_DiscoRaytracer_h
+
+#include <Interface/Renderer.h>
+
+#include <disco_demo/Interface/PerSampleShader.h>
+
+namespace Manta {
+ class SetupContext;
+ class RenderContext;
+ class RayPacket;
+};
+
+namespace disco {
+
+ using namespace Manta;
+
+ class DiscoRayTracer : public Renderer {
+ public:
+ // Constructors
+ DiscoRayTracer( PerSampleShader *per_sample_shader_ );
+ virtual ~DiscoRayTracer();
+
+ // Renderer Interface
+ virtual void setupBegin(const SetupContext&, int numChannels);
+ virtual void setupDisplayChannel(SetupContext&);
+ virtual void setupFrame(const RenderContext& context);
+
+ // These functions should not be called.
+ virtual void traceEyeRays(const RenderContext&, RayPacket& rays);
+ virtual void traceRays(const RenderContext&, RayPacket& rays);
+
+ // These methods should be used instead.
+ virtual void traceEyeRays(const RenderContext& context, TilePacket&
tile_packet);
+ virtual void traceRays(const RenderContext& context, TilePacket&
tile_packet);
+
+ // Accessors.
+ PerSampleShader *getPerSampleShader() { return per_sample_shader; };
+
+ private:
+ PerSampleShader *per_sample_shader;
+
+ DiscoRayTracer(const DiscoRayTracer&);
+ DiscoRayTracer& operator=(const DiscoRayTracer&);
+ };
+}
+
+#endif
Added: trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/Shaders/AOShader.cc Mon Jan 9 04:15:17
2006
@@ -0,0 +1,370 @@
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+// Abe Stephens
+
+#include <disco_demo/Engine/Shaders/AOShader.h>
+
+#include <MantaTypes.h>
+#include <Interface/Context.h>
+#include <Interface/Primitive.h>
+#include <Interface/Scene.h>
+#include <Core/Geometry/PointVector.h>
+#include <Core/Math/MT_RNG.h>
+#include <SCIRun/Core/Math/Trig.h>
+
+#include <iostream>
+
+#include <disco_demo/Interface/DiscoTile.h>
+
+
+using namespace Manta;
+using namespace disco;
+using namespace disco::ambient_occlusion;
+
+static int primes[] = { 2, 3, 5, 7 };
+
+inline Real radical_inverse( int n, int b ) {
+
+ Real val = 0;
+ Real inv_b = 1.0 / (Real)b;
+ Real inv_bi = inv_b;
+
+ while (n > 0) {
+ int di = n % b;
+ val += di * inv_bi;
+ n /= b;
+ inv_bi *= inv_b;
+ }
+
+ return val;
+};
+
+inline Real folded_radical_inverse( int n, int b ) {
+
+ Real val = 0;
+ Real inv_b = 1.0 / (Real)b;
+ Real inv_bi = inv_b;
+ int offset = 0;
+
+ while ((val+b*inv_bi) != val) {
+ int d = ((n+offset) % b);
+ val += d * inv_bi;
+ n /= b;
+ inv_bi *= inv_b;
+ ++offset;
+ }
+
+ return val;
+};
+
+template< typename T, int S >
+class HaltonSequence {
+public:
+ HaltonSequence( int n_ = 1 ) : n( n ) { };
+
+ // Generate the next number in the sequence.
+ void next( PointT<T,S> &p ) {
+ for (int i=0;i<S;++i) {
+ p[i] = folded_radical_inverse( n, primes[i] );
+ }
+ ++n;
+ }
+
+private:
+ int n;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Per sample shader.
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Setup
+
+void AOSampleShader::setupDisplayChannel(SetupContext& context) {
+
+ // Determine how much storage is needed for the direction vector.
+ size_t bytes = sizeof( Vector ) * total_directions;
+
+ // Request storage.
+ storage_token = context.storage_allocator->requestStorage( bytes, 128 );
+
+ if (context.proc == 0) {
+ generated = false;
+ }
+}
+
+// Per frame / per thread setup.
+void AOSampleShader::setupFrame(const RenderContext& context) {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generate directions.
+ if (!generated) {
+
+ // Obtain a pointer to the array.
+ Vector *directions = (Vector *)context.storage_allocator->get(
context.proc, storage_token );
+
+ /////////////////////////////////////////////////////////////////////////
+ // Generate cosine weighted directions
+ // MT_RNG rng;
+ HaltonSequence<Real,2> sequence( context.proc*100 );
+ PointT<Real,2> p;
+
+ for ( int i = 0; i < total_directions; i++ ) {
+ // Real r1 = rng.genRealRand<Real>();
+ // Real r2 = rng.genRealRand<Real>();
+
+ sequence.next( p );
+
+ Real phi = 2.0 * Pi * p[0];
+ Real r = sqrt( p[1] );
+ Real x = r * Cos(phi);
+ Real y = r * Sin(phi);
+ Real z = 1.0 - x*x - y*y;
+ z = (z > 0.0) ? Sqrt(z) : 0.0;
+
+ directions[i] = Vector(x, y, z);
+ }
+ }
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Shader Method
+void AOSampleShader::shade( const RenderContext &context, TilePacket &packet
) {
+
+ // Obtain a pointer to the array.
+ Vector *directions = (Vector *)context.storage_allocator->get(
context.proc, storage_token );
+
+ if (context.proc == 0) {
+ generated = true;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Compute normals and hit positions.
+ packet.computeNormals(context);
+ packet.computeHitPositions();
+
+ // Set ray packet colors.
+ //shade_materials( context, packet );
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Compute local coordinate system for each hit position.
+ Vector V[RayPacket::MaxSize];
+ Vector U[RayPacket::MaxSize];
+ Vector W[RayPacket::MaxSize];
+
+ for (int i=0;i<packet.getSize();++i) {
+
+ RayPacket::Element &e = packet.get(i);
+
+ W[i] = e.normal;
+ W[i].normalize();
+
+ // Determine if W can be crossed with 1,0,0
+ Real d = Dot( W[i],Vector(1,0,0));
+ if ((1.0-d) < 1e-6)
+ U[i] = Cross( W[i], Vector(0,1,0) );
+ else
+ U[i] = Cross( W[i], Vector(1,0,0) );
+ U[i].normalize();
+
+ V[i] = Cross( W[i], U[i] );
+
+ }
+
+ // Create a ray packet for shooting secondary rays.
+ RayPacketData secondary_data;
+ RayPacket secondary_packet( secondary_data, 0, 1, 0 );
+
+ int secondary_size = 0;
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Decide which directions to shoot based on TilePacket element task id.
+ int task_size = total_directions / kernel_width;
+
+ for (int i=0;i<packet.getSize();++i) {
+ TilePacket::Element &p = packet.getTilePacketElement( i );
+ RayPacket::Element &e = packet.getRayPacketElement ( i );
+
+ if (e.hitInfo.wasHit()) {
+
+ int d = p.task*task_size;
+ int d_end = d+task_size;
+
+ Real total_hit = 0.0;
+ Real total_sent = 0.0;
+
+ for (;d<d_end;++d) {
+
+ // Transform the precomputed direction to the local coordinate system
+ // of the hit.
+ Vector dir =
+ directions[d][0]*U[i] +
+ directions[d][1]*V[i] +
+ directions[d][2]*W[i];
+
+ // Add a ray to the outgoing packet.
+ RayPacket::Element &out = secondary_packet.get( secondary_size++ );
+
+ // Initialize the ray.
+ out.ray.set( e.hitPosition, dir );
+ out.hitInfo.reset( ambient_cutoff );
+ ++total_sent;
+
+ // Check to see if the packet is filled.
+ if (secondary_size == RayPacket::MaxSize) {
+
+
/////////////////////////////////////////////////////////////////////
+ // Send the ray packet.
+ secondary_packet.resize( secondary_size );
+ context.scene->getObject()->intersect( context, secondary_packet );
+
+ // Count how many hit.
+ for (int j=0;j<secondary_packet.getSize();++j) {
+ if (secondary_packet.get(j).hitInfo.wasHit()) {
+ ++total_hit;
+ }
+ }
+
+
/////////////////////////////////////////////////////////////////////
+ // Reset the secondary packet.
+ secondary_packet.setAllFlags( 0 );
+ secondary_size = 0;
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ // Check to see if there are any secondary rays left over.
+ secondary_packet.resize( secondary_size );
+ context.scene->getObject()->intersect( context, secondary_packet );
+
+ // Count how many hit.
+ for (int j=0;j<secondary_packet.getSize();++j) {
+ if (secondary_packet.get(j).hitInfo.wasHit()) {
+ ++total_hit;
+ }
+ }
+
+ secondary_packet.setAllFlags( 0 );
+ secondary_size = 0;
+
+
////////////////////////////////////////////////////////////////////////
+ // Determine hit ratio.
+ p.scratch_pad<DiscoInfo>().hit_ratio = ( total_hit / total_sent );
+
+ }
+ else {
+ p.scratch_pad<DiscoInfo>().hit_ratio = 1.0;
+ }
+ }
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Neighborhood shader.
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Setup
+
+void AONeighborhoodShader::setupDisplayChannel(SetupContext& context) {
+}
+
+void AONeighborhoodShader::setupFrame(const RenderContext& context) {
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Shader method
+void AONeighborhoodShader::shade( const RenderContext &context,
+ DiscoTile *disco_tile,
+ TilePacket &packet ) {
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Filter the hit ratios from neighboring pixels.
+ for (int i=0;i<packet.getSize();++i) {
+
+ TilePacket::Element &p = packet.getTilePacketElement( i );
+
+ // Check to see if the element is part of the tile.
+ if (!p.overlap) {
+ RayPacket::Element &e = packet.get( i );
+
+ // Make sure the element generated a hit.
+ if (e.hitInfo.wasHit()) {
+
+ // Determine the location of this element.
+ int x = p.tilex;
+ int y = p.tiley;
+
+ Real sum = 0.0;
+
+
///////////////////////////////////////////////////////////////////////
+ // Convolve.
+ int half_width = (kernel_width-1)/2;
+
+ // Use an averaging filter.
+ Real filter_value = 1.0/(Real)(kernel_width*kernel_width);
+
+ for (int y_offset=-half_width;y_offset<=half_width;++y_offset) {
+ for (int x_offset=-half_width;x_offset<=half_width;++x_offset) {
+
+ if (disco_tile->getRayPacketElement( x+x_offset,y+y_offset
).hitInfo.wasHit()) {
+
+ // Look up the neighbor value.
+ Real hit_ratio =
+ disco_tile->
+ getTilePacketElement( x+x_offset,
+ y+y_offset
).scratch_pad<DiscoInfo>().hit_ratio;
+
+ // Sum up all of the neighbors.
+ sum += hit_ratio * filter_value;
+ }
+
+ }
+ }
+
+ // Color the pixel
+ sum = 1.0 - sum;
+ e.color = /*e.color **/ Color(RGB(sum,sum,sum));
+ }
+ else {
+ // Background color.
+ e.color = Color(RGB(0.4,0.4,0.2));
+ }
+ }
+ }
+
+}
+
Added: trunk/fox/disco_demo/Engine/Shaders/AOShader.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/Shaders/AOShader.h Mon Jan 9 04:15:17
2006
@@ -0,0 +1,105 @@
+#ifndef disco_AmbientOcclusion__H
+#define disco_AmbientOcclusion__H
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+
+// Abe Stephens
+
+#include <Core/Util/ThreadStorage.h>
+#include <MantaTypes.h>
+#include <disco_demo/Interface/TilePacket.h>
+
+#include <disco_demo/Interface/PerSampleShader.h>
+#include <disco_demo/Interface/NeighborhoodShader.h>
+
+
+namespace Manta {
+ class SetupContext;
+ class RenderContext;
+ class PreprocessContext;
+};
+
+namespace disco {
+
+ class DiscoTile;
+
+
+ namespace ambient_occlusion {
+
+ using namespace Manta;
+
+ struct DiscoInfo {
+ Real hit_ratio;
+ };
+
+ // Per-sample shader.
+ class AOSampleShader : public PerSampleShader {
+ public:
+ AOSampleShader( int kernel_width_, int total_directions_, Real
ambient_cutoff_ )
+ : kernel_width( kernel_width_ ),
+ total_directions( total_directions_ ),
+ ambient_cutoff( ambient_cutoff_ ) { };
+
+ virtual void setupDisplayChannel(SetupContext& context);
+ virtual void setupFrame(const RenderContext& context);
+
+ virtual void shade( const RenderContext &context, TilePacket &packet );
+
+ private:
+ // Members.
+ int generated;
+ int total_directions;
+ int kernel_width;
+ Real ambient_cutoff;
+
+ // Storage
+ ThreadStorage::Token storage_token;
+ };
+
+ // Neighborhood shader.
+ class AONeighborhoodShader : public NeighborhoodShader {
+ public:
+ AONeighborhoodShader( int kernel_width_ ) :
+ kernel_width( kernel_width_ ) { };
+
+ virtual void setupDisplayChannel(SetupContext& context);
+ virtual void setupFrame(const RenderContext& context);
+
+ virtual void shade( const RenderContext &context,
+ DiscoTile *disco_tile,
+ TilePacket &packet );
+ private:
+ int kernel_width;
+ };
+ };
+};
+
+#endif
+
+
Added: trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.cc Mon Jan 9
04:15:17 2006
@@ -0,0 +1,100 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+
+// Abe Stephens
+
+#include <disco_demo/Engine/Shaders/DepthMapShader.h>
+
+#include <Interface/Context.h>
+
+#include <disco_demo/Interface/TilePacket.h>
+
+using namespace Manta;
+using namespace disco;
+using namespace disco::depth_map;
+
+///////////////////////////////////////////////////////////////////////////////
+// Per sample shader.
+
+void DepthSampleShader::preprocess( const PreprocessContext &) {
+
+
+}
+
+void DepthSampleShader::shade( const RenderContext &context, TilePacket
&packet ) {
+
+ // shade_materials( context, packet );
+
+ for (int i=0;i<packet.getSize();++i) {
+
+ DiscoScratchInfo &info = packet.getTilePacketElement( i
).scratch_pad<DiscoScratchInfo>();
+ RayPacket::Element &e = packet.getRayPacketElement( i );
+ TilePacket::Element &p = packet.getTilePacketElement( i );
+
+ if (e.hitInfo.wasHit()) {
+ info.depth = e.hitInfo.minT();
+ }
+ else {
+ ASSERT(false); // shouldn't get misses anymore.
+ info.depth = 1000.0;
+ }
+ }
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Neighborhood shader.
+
+void DepthNeighborhoodShader::preprocess( const PreprocessContext &) {
+}
+
+void DepthNeighborhoodShader::shade( const RenderContext &context,
+ DiscoTile *disco_tile,
+ TilePacket &packet ) {
+
+
+
+
+ for (int i=0;i<packet.getSize();++i) {
+
+ DiscoScratchInfo &info = packet.getTilePacketElement( i
).scratch_pad<DiscoScratchInfo>();
+ TilePacket::Element &p = packet.getTilePacketElement( i );
+
+ if (!p.overlap) {
+
+ if (packet.hitInfo(i).wasHit()) {
+ // Colormap the depth.
+ Real d = (20.0 - info.depth) / 20.0;
+ packet.get(i).color = Color(RGB(d,d,d));
+ }
+ else {
+ packet.get(i).color = Color(RGB(1,0,0));
+ }
+ }
+ }
+}
Added: trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.h Mon Jan 9
04:15:17 2006
@@ -0,0 +1,74 @@
+#ifndef disco_DepthMapShader__H
+#define disco_DepthMapShader__H
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+
+// Abe Stephens
+
+#include <MantaTypes.h>
+
+#include <disco_demo/Interface/PerSampleShader.h>
+#include <disco_demo/Interface/NeighborhoodShader.h>
+
+namespace disco {
+ namespace depth_map {
+
+ struct DiscoScratchInfo {
+ Real depth;
+ };
+
+ // Per-sample shader.
+ class DepthSampleShader : public PerSampleShader {
+ public:
+ virtual void setupDisplayChannel(SetupContext& context) { }
+ virtual void setupFrame(const RenderContext& context) { };
+
+ virtual void preprocess( const PreprocessContext &);
+ virtual void shade( const RenderContext &context, TilePacket &packet );
+ };
+
+ // Neighborhood shader.
+ class DepthNeighborhoodShader : public NeighborhoodShader {
+ public:
+ virtual void setupDisplayChannel(SetupContext& context) { }
+ virtual void setupFrame(const RenderContext& context) { }
+
+ virtual void preprocess( const PreprocessContext &);
+ virtual void shade( const RenderContext &context,
+ DiscoTile *disco_tile,
+ TilePacket &packet );
+ };
+
+ };
+
+};
+
+
+#endif
+
Added: trunk/fox/disco_demo/Interface/CMakeLists.txt
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/CMakeLists.txt Mon Jan 9 04:15:17
2006
@@ -0,0 +1 @@
+
Added: trunk/fox/disco_demo/Interface/DiscoTile.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/DiscoTile.cc Mon Jan 9 04:15:17 2006
@@ -0,0 +1,110 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <disco_demo/Interface/DiscoTile.h>
+
+using namespace Manta;
+using namespace disco;
+
+size_t compute_size( int xtilesize, int ytilesize, int overlap ) {
+
+ // Total number of pixels.
+ size_t total_pixels = (xtilesize+2*overlap) * (ytilesize+2*overlap);
+
+ // Determine amount of space for ray packet elements and
+ // tile packet elements.
+ size_t raypacket_bytes = total_pixels * sizeof(RayPacket::Element);
+ size_t tilepacket_bytes = total_pixels * sizeof(TilePacket::Element);
+
+ // Determine how much continous space for the whole structure
+ // including arrays. With buffer space for aligning the arrays to cache.
+ size_t total_bytes =
+ sizeof(DiscoTile) +
+ raypacket_bytes +
+ tilepacket_bytes +
+ 128*3;
+
+ return total_bytes;
+}
+
+
+ThreadStorage::Token DiscoTile::requestStorage( ThreadStorage &storage,
+ int xtilesize,
+ int ytilesize,
+ int overlap )
+{
+ size_t total_bytes = compute_size( xtilesize, ytilesize, overlap );
+
+ // Request the storage.
+ return storage.requestStorage( total_bytes, 128 );
+}
+
+// Initialize DiscoTile of a given size in thread local storage.
+void *DiscoTile::operator new( size_t bytes,
+ const ThreadStorage::Allocator &allocator,
+ int xtilesize,
+ int ytilesize,
+ int overlap ) {
+
+ // Obtain a pointer to the tile
+ DiscoTile *disco_tile = (DiscoTile *)(*allocator);
+
+ // Initialize.
+ disco_tile->width = xtilesize+2*overlap;
+ disco_tile->height = ytilesize+2*overlap;
+ disco_tile->overlap = overlap;
+ disco_tile->total = disco_tile->width * disco_tile->height;
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Compute offsets into the memory for each array.
+ size_t allocated = sizeof(DiscoTile);
+ size_t raypacket_offset = ((allocated/128)+1)*128;
+
+ allocated = raypacket_offset + (disco_tile->total *
sizeof(RayPacket::Element));
+ size_t tilepacket_offset = ((allocated/128)+1)*128;
+
+ // Point arrays to allocated memory.
+ disco_tile->raypacket_data = (RayPacket::Element *)((char *)disco_tile +
raypacket_offset);
+ disco_tile->tilepacket_data = (TilePacket::Element *)((char *)disco_tile +
tilepacket_offset);
+
+ // Sanity check.
+ size_t total_pixels = (xtilesize+2*overlap) * (ytilesize+2*overlap);
+ size_t tilepacket_bytes = total_pixels * sizeof(TilePacket::Element);
+
+ size_t requested_size = compute_size( xtilesize, ytilesize, overlap );
+ size_t actual_size = (size_t) ((char *)disco_tile->tilepacket_data +
tilepacket_bytes);
+
+ actual_size = actual_size - (size_t)disco_tile;
+
+ ASSERT(actual_size < requested_size);
+
+ return disco_tile;
+}
+
+
+
Added: trunk/fox/disco_demo/Interface/DiscoTile.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/DiscoTile.h Mon Jan 9 04:15:17 2006
@@ -0,0 +1,131 @@
+#ifndef disco_DiscoTile__H
+#define disco_DiscoTile__H
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Core/Util/ThreadStorage.h>
+#include <disco_demo/Interface/TilePacket.h>
+
+namespace Manta {
+ class RayPacket;
+};
+
+namespace disco {
+
+ using namespace Manta;
+
+
/////////////////////////////////////////////////////////////////////////////
+
/////////////////////////////////////////////////////////////////////////////
+ // This class is used to access memory in thread local storage of the
+ // DiscoImageTraverser.
+ class DiscoTile {
+ public:
+
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ // Initialization from ThreadLocal Storage.
+ static ThreadStorage::Token requestStorage( ThreadStorage &storage,
+ int xtilesize,
+ int ytilesize,
+ int overlap = 1 );
+
+ // Initialize DiscoTile of a given size in thread local storage.
+ void *DiscoTile::operator new( size_t bytes,
+ const ThreadStorage::Allocator &allocator,
+ int xtilesize,
+ int ytilesize,
+ int overlap = 1);
+
+ DiscoTile() { }; // Use thread local storage methods.
+
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ // Tile coordinate Accessors
+ RayPacket::Element &DiscoTile::getRayPacketElement( int x, int y ) {
+
+ // Shift so that overlap requires negative coordinates.
+ int offset = get_offset( x+overlap, y+overlap );
+ ASSERT(offset < total);
+ return raypacket_data[offset];
+ }
+
+ TilePacket::Element &DiscoTile::getTilePacketElement( int x, int y ) {
+
+ // Shift so that overlap requires negative coordinates.
+ int offset = get_offset( x+overlap, y+overlap );
+ ASSERT(offset < total);
+ return tilepacket_data[offset];
+ }
+
+
/////////////////////////////////////////////////////////////////////////..
+ // TilePacket Accessors, caller is responsible for determining size.
+ RayPacketData &getRayPacketData( int i ) {
+ size_t index = i*RayPacket::MaxSize;
+ ASSERT(index < total);
+ return *((RayPacketData *)&raypacket_data[i*RayPacket::MaxSize]);
+ };
+
+ TilePacketData &getTilePacketData( int i ) {
+ size_t index = i*RayPacket::MaxSize;
+ ASSERT(index < total);
+ return *((TilePacketData *)&tilepacket_data[i*RayPacket::MaxSize]);
+ };
+
+ int getPacketSize( int i ) {
+ int rounded = (total/RayPacket::MaxSize);
+ if (i < rounded) {
+ return RayPacket::MaxSize;
+ }
+ return total % RayPacket::MaxSize;
+ }
+
+ int getTotalElements() { return total; }
+
+ private:
+
+ // Array indexing.
+ int get_offset( int x, int y ) { return y*(width) + x; }
+
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ // Actual Dimensions (including overlap)
+ int width;
+ int height;
+
+ int overlap;
+ int total;
+
+ // Arrays
+ RayPacket::Element *raypacket_data;
+ TilePacket::Element *tilepacket_data;
+ };
+};
+
+
+#endif
Added: trunk/fox/disco_demo/Interface/NeighborhoodShader.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/NeighborhoodShader.cc Mon Jan 9
04:15:17 2006
@@ -0,0 +1,37 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <disco_demo/Interface/NeighborhoodShader.h>
+
+using namespace Manta;
+using namespace disco;
+
+NeighborhoodShader::~NeighborhoodShader() { };
+
+
+
Added: trunk/fox/disco_demo/Interface/NeighborhoodShader.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/NeighborhoodShader.h Mon Jan 9 04:15:17
2006
@@ -0,0 +1,68 @@
+
+#ifndef disco_NeighborhoodShader__H
+#define disco_NeighborhoodShader__H
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+namespace Manta {
+ class RayPacket;
+ class PreprocessContext;
+ class RenderContext;
+ class SetupContext;
+};
+
+namespace disco {
+
+ using namespace Manta;
+
+ class DiscoTile;
+ class TilePacket;
+
+ class NeighborhoodShader {
+ public:
+ NeighborhoodShader() { };
+ virtual ~NeighborhoodShader();
+
+ // Setup methods, these may be used to request and initialize
+ // thread local storage.
+ virtual void setupDisplayChannel(SetupContext& context) = 0;
+ virtual void setupFrame(const RenderContext& context) = 0;
+
+ // Shader method.
+ virtual void shade( const RenderContext &context,
+ DiscoTile *disco_tile,
+ TilePacket &packet ) = 0;
+ private:
+ NeighborhoodShader(const NeighborhoodShader&);
+ NeighborhoodShader& operator=(const NeighborhoodShader&);
+ };
+
+};
+
+#endif
Added: trunk/fox/disco_demo/Interface/PerSampleShader.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/PerSampleShader.cc Mon Jan 9 04:15:17
2006
@@ -0,0 +1,84 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <disco_demo/Interface/PerSampleShader.h>
+
+#include <Core/Util/Assert.h>
+#include <Interface/Background.h>
+#include <Interface/Camera.h>
+#include <Interface/Context.h>
+#include <Interface/Material.h>
+#include <Interface/Object.h>
+#include <Interface/RayPacket.h>
+#include <Interface/Scene.h>
+
+using namespace Manta;
+using namespace disco;
+
+PerSampleShader::~PerSampleShader() { };
+
+void PerSampleShader::shade_materials( const RenderContext &context,
RayPacket &rays ) {
+
+ // Go through the ray packet and shade them. Group rays that hit the
+ // same object and material to shade with a single shade call
+ for(int i = 0;i<rays.getSize();){
+
+ if(rays.hitInfo(i).wasHit()) {
+
+ const Material* hit_matl = rays.hitInfo(i).hitMaterial();
+
+ // Find consecutive rays which hit this material.
+ int end = i+1;
+ while(end < rays.getSize() && rays.hitInfo(end).wasHit() &&
+ rays.hitInfo(end).hitMaterial() == hit_matl)
+ end++;
+
+ // Create a sub packet.
+ RayPacket subPacket(rays, i, end);
+
+ // Shade the sub packet.
+ hit_matl->shade(context, subPacket);
+
+ i=end;
+
+ } else {
+
+ // Find consecutive ray which don't hit anything.
+ int end = i+1;
+ while(end < rays.getSize() && !rays.hitInfo(end).wasHit())
+ end++;
+
+ RayPacket subPacket(rays, i, end);
+
+ // Use the background shader.
+ context.scene->getBackground()->shade(context, subPacket);
+
+ i=end;
+ }
+ }
+}
Added: trunk/fox/disco_demo/Interface/PerSampleShader.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/PerSampleShader.h Mon Jan 9 04:15:17
2006
@@ -0,0 +1,69 @@
+
+#ifndef disco_PerSampleShader__H
+#define disco_PerSampleShader__H
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+namespace Manta {
+ class PreprocessContext;
+ class RenderContext;
+ class SetupContext;
+ class RayPacket;
+};
+
+namespace disco {
+
+ using namespace Manta;
+
+ class TilePacket;
+
+ class PerSampleShader {
+ public:
+ PerSampleShader() { };
+ virtual ~PerSampleShader();
+
+ // Setup methods in the render stack.
+ virtual void setupDisplayChannel(SetupContext& context) = 0;
+ virtual void setupFrame(const RenderContext& context) = 0;
+
+ // Shader method.
+ virtual void shade( const RenderContext &context, TilePacket &packet ) =
0;
+
+ protected:
+ // Helper method which performs the usual raypacket material shading.
+ static void shade_materials( const RenderContext &context, RayPacket
&rays );
+
+ private:
+ PerSampleShader(const PerSampleShader&);
+ PerSampleShader& operator=(const PerSampleShader&);
+ };
+
+};
+
+#endif
Added: trunk/fox/disco_demo/Interface/TilePacket.h
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/Interface/TilePacket.h Mon Jan 9 04:15:17 2006
@@ -0,0 +1,99 @@
+
+#ifndef disco_TilePacket__H
+#define disco_TilePacket__H
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+// Abe Stephens
+
+#include <Interface/RayPacket.h>
+#include <Interface/HitInfo.h>
+
+namespace disco {
+
+ using namespace Manta;
+
+ class TilePacketData;
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TilePacket data structure for accessing neighboring samples and storing
+ // per sample results
+ class TilePacket : public RayPacket {
+ public:
+ enum { MaxScratchpadSize = HitInfo::MaxScratchpadSize };
+
+ // Tile Element
+ class Element {
+ public:
+ int tilex, tiley;
+ int overlap;
+ int task;
+
+ private:
+ char scratch_pad_data[MaxScratchpadSize];
+
+ public:
+ // Scratch pad accessor.
+ template< typename T >
+ T &scratch_pad() { return *(T*)scratch_pad_data; };
+ };
+
+ // Constructor.
+ TilePacket( RayPacketData &raypacket_data, TilePacketData
&tilepacket_data,
+ int size_, int depth_ = 0, int flags_ = 0 );
+
+ // Sub packet constructor.
+ TilePacket( const TilePacket &packet, int start, int end )
+ : RayPacket( (RayPacket &)packet, start, end ), data(
&packet.data[start] ) { }
+
+ // Element accessors.
+ RayPacket::Element &getRayPacketElement ( int i ) { return
RayPacket::get( i );};
+ Element &getTilePacketElement( int i ) { return data[i]; };
+
+ private:
+ // Size member of the ray packet is used.
+ Element *data;
+ };
+
+ class TilePacketData {
+ private:
+ TilePacket::Element data[RayPacket::MaxSize];
+ friend class TilePacket;
+ };
+
+ // Constructor.
+ inline TilePacket::TilePacket( RayPacketData &raypacket_data,
TilePacketData &tilepacket_data,
+ int size_, int depth_, int flags_ )
+
+ : RayPacket( raypacket_data, size_, depth_, flags_ ),
+ data( &tilepacket_data.data[0] ) { }
+
+};
+
+#endif
Added: trunk/fox/disco_demo/StandAlone/CMakeLists.txt
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/StandAlone/CMakeLists.txt Mon Jan 9 04:15:17
2006
@@ -0,0 +1,9 @@
+
+##########################################################
+# Add the disc_demo program
+ADD_EXECUTABLE (disco_demo disco_demo.cc)
+
+TARGET_LINK_LIBRARIES(disco_demo
+ FManta_static
+ disco_shared
+ )
Added: trunk/fox/disco_demo/StandAlone/disco_demo.cc
==============================================================================
--- (empty file)
+++ trunk/fox/disco_demo/StandAlone/disco_demo.cc Mon Jan 9 04:15:17
2006
@@ -0,0 +1,410 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+
+// Abe Stephens
+
+#include <Interface/MantaInterface.h>
+#include <Core/Color/ColorDB.h>
+#include <Core/Util/Args.h>
+#include <Interface/Callback.h>
+#include <Interface/Scene.h>
+#include <Interface/Camera.h>
+#include <Interface/Context.h>
+
+#include <X11/Xlib.h>
+
+#include <Engine/Display/GLXImageDisplay.h>
+#include <Model/Cameras/PinholeCamera.h>
+
+#include <FManta/FMantaWindow.h>
+#include <FManta/FMantaUniformNav.h>
+#include <FManta/FMantaQuakeNav.h>
+#include <FManta/FMantaTrackballNav.h>
+#include <FManta/FMantaWidgets.h>
+
+#include <FManta/FMantaStereo.h>
+#include <FManta/FMantaKdExplorer.h>
+
+#include <string>
+#include <stdlib.h>
+#include <fstream>
+
+using namespace FX;
+using namespace fox_manta;
+using namespace Manta;
+using namespace std;
+
+#include <Model/Groups/KDTree.h>
+#include <Model/Materials/Flat.h>
+using namespace Manta::Kdtree;
+
+#include <disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h>
+#include <disco_demo/Engine/Renderers/DiscoRayTracer.h>
+#include <disco_demo/Engine/Shaders/DepthMapShader.h>
+#include <disco_demo/Engine/Shaders/AOShader.h>
+
+using namespace disco;
+using namespace disco::depth_map;
+using namespace disco::ambient_occlusion;
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+// XXX to be replaced!
+namespace fox_manta {
+ KDTree *__global_kdtree = NULL;
+}
+
+Scene* createDefaultScene();
+
+int main( int argc, char *argv[]) {
+
+ // Make sure the necessary environment is setup.
+ if (getenv("THREAD_NO_CATCH_SIGNALS") == 0) {
+ cerr << "ALERT: setenv THREAD_NO_CATCH_SIGNALS 1 to avoid
instability on exit." << std::endl;
+ };
+ if (getenv("FGL_MACRO_TILE_FB") == 0) {
+ cerr << "ALERT: setenv FGL_MACRO_TILE_FB 1 to improve
performance over vizserver." << std::endl;
+ }
+
+ // Parse args.
+ int np = 1;
+ char *scene_text = 0;
+ string bookmark_file_name;
+
+ string default_camera = "pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 0
0 1 -fov 60)";
+ string default_imagetraverser = "tiled";
+ string default_pixelsampler = "singlesample";
+
+ bool use_stereo = false;
+
+
+ // Look for specific args.
+ for (int i=0;i<argc;++i) {
+ string arg = argv[i];
+ if (arg == "-np") {
+ np = atoi( argv[++i] );
+ }
+ else if (arg == "-scene") {
+ scene_text = argv[++i];
+ }
+ else if (arg == "-bookmarks") {
+ bookmark_file_name = argv[++i];
+ }
+ else if (arg == "-stereo") {
+ use_stereo = true;
+ }
+ else if (arg == "-camera") {
+ default_camera = argv[++i];
+ }
+ }
+
+ std::cerr << "Using " << np << " workers plus one gui thread." <<
std::endl;
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Make a fox application object.
+ FXApp app( "", "Abe Stephens" );
+ app.init( argc, argv );
+
+ int width = 512;
+ int height = 512;
+
+ // Add an FMantaWindow.
+ FMantaWindow manta_window( &app,
+ argv[0],
+ true,
+ width, height );
+
+ // Create the application's windows.
+ app.create();
+
+ // Setup the manta pipeline.
+ MantaInterface *manta_interface = 0;
+ GLXImageDisplay *glx_image_display = 0;
+
+ try {
+
+
///////////////////////////////////////////////////////////////////////////
+ // Construct Manta.
+ manta_interface = createManta();
+
+ manta_interface->setScenePath (".");
+ manta_interface->changeNumWorkers ( np );
+ manta_interface->selectImageType ( "rgba8" );
+ manta_interface->selectLoadBalancer ( "workqueue" );
+ manta_interface->selectShadowAlgorithm( "hard" );
+
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+
+ // DepthSampleShader *sample_shader = new DepthSampleShader;
+ // DepthNeighborhoodShader *neighborhood_shader = new
DepthNeighborhoodShader;
+
+ int ambient_rays = 9;
+ Real ambient_cutoff = 10.0;
+ int tilex = 8;
+ int tiley = 8;
+ int kernel_width = 3;
+
+ for (int i=0;i<argc;++i) {
+ string arg = argv[i];
+ if (arg == "-rays") {
+ ambient_rays = atoi( argv[++i] );
+ }
+ else if (arg == "-cutoff") {
+ ambient_cutoff = atof( argv[++i] );
+ }
+ else if (arg == "-size") {
+ getResolutionArg( (argv[++i]), tilex, tiley );
+ }
+ else if (arg == "-kernel") {
+ kernel_width = atoi( argv[++i] );
+ }
+ };
+
+ PerSampleShader *sample_shader = new AOSampleShader( kernel_width,
ambient_rays, ambient_cutoff );
+ NeighborhoodShader *neighborhood_shader = new AONeighborhoodShader(
kernel_width );
+
+ DiscoRayTracer *disco_renderer = new DiscoRayTracer( sample_shader );
+ DiscoImageTraverser *disco_image_traverser
+ = new DiscoImageTraverser( tilex, tiley,
+ (kernel_width-1)/2, // Overlap.
+ disco_renderer,
+ neighborhood_shader );
+
+ manta_interface->setImageTraverser( disco_image_traverser );
+ manta_interface->setRenderer ( disco_renderer );
+
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+
+ // Create the manta image frame.
+ FMantaImageFrame *manta_frame = manta_window.getMantaFrame();
+
+ // Create a glx image display.
+ glx_image_display =
+ new GLXImageDisplay( (XVisualInfo
*)manta_frame->getVisual()->getInfo(),
+ (Window) manta_frame->id() );
+
+
///////////////////////////////////////////////////////////////////////////
+ // Try to load a scene.
+ if ((scene_text == 0) || (!manta_interface->readScene( scene_text ))) {
+ // Create a default scene.
+ manta_interface->setScene( createDefaultScene() );
+ }
+
+ Object *root_object = manta_interface->getScene()->getObject();
+
+
///////////////////////////////////////////////////////////////////////////
+ // Check to see if the camera should be automatically positioned.
+ if (default_camera == "auto") {
+
+ // Find the bounds of the model.
+ BBox bounds;
+ PreprocessContext context;
+ root_object->computeBounds( context, bounds );
+
+ Point lookat = bounds[0] + (bounds[1] - bounds[0]) * 0.5;
+ Point eye = lookat + Vector( 0, bounds.diagonal().length(), 0 );
+ Vector up( 0, 0, 1 );
+
+ ostringstream oss;
+ oss << "pinhole( -eye " << eye << " -lookat " << lookat << " -up " <<
up << " -fov 60 )";
+
+ default_camera = oss.str();
+
+ std::cerr << "Auto camera: " << default_camera << std::endl;
+ }
+
+
///////////////////////////////////////////////////////////////////////////
+ // Check to see if a bookmark file was specified.
+ if (bookmark_file_name.size() > 0) {
+
+ char description[128];
+ char specification[128];
+ ifstream file( bookmark_file_name.c_str() );
+
+ if (file.is_open()) {
+ while (!file.eof()) {
+
+ file.getline( description, 128 );
+ if (string(description).size() > 0) {
+
+ file.getline( specification, 128 );
+ if (string(specification).size() > 0) {
+ manta_window.addCameraBookmark( description, specification );
+ }
+ }
+ }
+
+ file.close();
+ }
+ else {
+ std::cerr << "Could not load bookmark file." << std::endl;
+ }
+ }
+
+ // Add a camera bookmark for the default camera.
+ manta_window.addCameraBookmark( "Default", default_camera );
+
+ // Create the camera using the first camera bookmark.
+ Camera *camera = 0;
+ if ((camera = manta_interface->createCamera(
manta_window.getCameraBookmark( 0 ) )) == 0) {
+
+ std::cerr << "Error could not create camera: " << default_camera <<
std::endl;
+ return 1;
+ }
+
+ // Create a default quake navigator.
+ FMantaQuakeNav *quake_nav = new FMantaQuakeNav( false );
+ quake_nav->setMantaInterface( manta_interface );
+ manta_window.addNavigatorOption( "Video Game", quake_nav );
+
+ // Create a default quake navigator.
+ FMantaQuakeNav *fly_nav = new FMantaQuakeNav( true );
+ fly_nav->setMantaInterface( manta_interface );
+ manta_window.addNavigatorOption( "Fly", fly_nav );
+
+ // Create a navigator for the image frame.
+ FMantaTrackballNav *trackball_nav = new FMantaTrackballNav();
+ trackball_nav->setMantaInterface( manta_interface );
+ trackball_nav->setMantaFrame( manta_frame );
+ trackball_nav->setMantaChannel( 0 );
+ manta_window.addNavigatorOption("Trackball", trackball_nav );
+
+ // Use the quake nav by default.
+ quake_nav->resetToCamera(
camera->getPosition(),camera->getLookAt(),camera->getUp());
+ manta_window.setNavigator( quake_nav );
+
+ // Create manta channel for the interface.
+ int manta_channel = 0;
+ manta_interface->createChannel( glx_image_display, camera, use_stereo,
width, height );
+
+ // Set the manta interface for the application.
+ manta_window.setMantaInterface( manta_interface, manta_channel );
+
+ // Check to see if we should enable the stereo dialog.
+ if (use_stereo) {
+ manta_window.addExtraOptionsDialog( "Stereo", new FMantaStereoDialog(
&manta_window, "Stereo" ));
+
+ // Add a transaction to switch on the stereo camera.
+ PinholeCamera *pinhole = dynamic_cast<PinholeCamera *>( camera );
+ if (pinhole) {
+
+ // Only set the stereo offset if it has not already been set.
+ if (pinhole->getStereoOffset() == 0.0) {
+
+ manta_interface->addTransaction("Switch to stereo",
+
Callback::create(pinhole,&PinholeCamera::setStereoOffset,(Real)0.1) );
+ }
+ }
+ }
+
+ // Check to see if the default scene was a kdtree.
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Create any necessary dialogs now since everything else should be
initialized.
+ KDTree *kdtree = 0;
+ if ((kdtree = dynamic_cast<KDTree *>( root_object ))) {
+
+ // XXX to be replaced
+ __global_kdtree = kdtree;
+
+ // Create a kdtree explorer dialog.
+ manta_window.addExtraOptionsDialog( "kd-Tree Explorer",
+ new FMantaKdExplorerDialog(
&manta_window, kdtree, "kd-Tree Explorer" ));
+ }
+
+ }
+ catch (SCIRun::Exception &e) {
+ std::cerr << "Could not setup Manta: " << e.message() << std::endl;
+ exit( 1 );
+ }
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Start up manta.
+ try {
+ manta_interface->beginRendering(false);
+
+ // Start fox control loop.
+ return app.run();
+ }
+ catch (SCIRun::Exception &e) {
+ std::cerr << "Caught exception at top level: " << e.message() <<
std::endl;
+ Thread::exitAll( 1 );
+ }
+}
+
+#include <Interface/LightSet.h>
+#include <Model/AmbientLights/ConstantAmbient.h>
+#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Lights/PointLight.h>
+#include <Model/Textures/Constant.h>
+#include <Model/Textures/CheckerTexture.h>
+#include <Model/Materials/Phong.h>
+#include <Model/Materials/Flat.h>
+#include <Model/Groups/Group.h>
+#include <Model/Primitives/Parallelogram.h>
+#include <Model/Primitives/Sphere.h>
+#include <Model/TexCoordMappers/UniformMapper.h>
+
+Scene* createDefaultScene()
+{
+ // Create a default scene. This scene is used for benchmarks, so
+ // please do not change it. Please create a new scene instead
+ Scene* scene = new Scene();
+ scene->setBackground(new
ConstantBackground(ColorDB::getNamedColor("SkyBlue3")*0.5));
+
+ Material* red=new Flat(Color(RGBColor(.6,0,0)));
+ Material* plane_matl = new Flat(new
CheckerTexture<Color>(Color(RGBColor(.6,.6,.6)),
+
Color(RGBColor(0,0,0)),
+ Vector(1,0,0),
+ Vector(0,1,0)));
+
+ Group* world = new Group();
+ Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
+
Vector(40,0,0), Vector(0,40,0));
+
+ // Setup world-space texture coordinates for the checkerboard floor
+ UniformMapper* uniformmap = new UniformMapper();
+ floor->setTexCoordMapper(uniformmap);
+ world->add(floor);
+ world->add(new Sphere(red, Point(0,0,1.2), 1.0));
+ scene->setObject(world);
+
+ LightSet* lights = new LightSet();
+ lights->add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
+ lights->add(new PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1))));
+ lights->add(new PointLight(Point(5,5,2), Color(RGBColor(.2,.2,.2))));
+ lights->setAmbientLight(new ConstantAmbient(Color::black()));
+ scene->setLights(lights);
+ scene->getRenderParameters().maxDepth = 5;
+ return scene;
+}
+
+
Modified: trunk/fox/dm_demo/dm_demo.cc
==============================================================================
--- trunk/fox/dm_demo/dm_demo.cc (original)
+++ trunk/fox/dm_demo/dm_demo.cc Mon Jan 9 04:15:17 2006
@@ -155,10 +155,19 @@
manta_interface->setScenePath (".");
manta_interface->changeNumWorkers ( np );
manta_interface->selectImageType ( "rgba8" );
- // manta_interface->selectImageType ( "rgbafloat" );
manta_interface->selectLoadBalancer ( "workqueue" );
- manta_interface->selectImageTraverser ( default_imagetraverser );
- manta_interface->selectPixelSampler ( default_pixelsampler );
+
+ // Check to see if image traverser and pixel sampler are found.
+ if (!manta_interface->selectImageTraverser ( default_imagetraverser )) {
+ std::cerr << "Invalid Image traverser: " << default_imagetraverser <<
std::endl;
+ return 1;
+ }
+
+ if (!manta_interface->selectPixelSampler ( default_pixelsampler )) {
+ std::cerr << "Invalid Pixel sampler: " << default_pixelsampler <<
std::endl;
+ return 1;
+ }
+
manta_interface->selectRenderer ( "raytracer" );
manta_interface->selectShadowAlgorithm( "hard" );
- [MANTA] r833 - in trunk: . Core/Util Engine/Control Interface fox fox/disco_demo fox/disco_demo/Engine fox/disco_demo/Engine/ImageTraversers fox/disco_demo/Engine/Renderers fox/disco_demo/Engine/Shaders fox/disco_demo/Interface fox/disco_demo/StandAlone fox/dm_demo, abe, 01/09/2006
Archive powered by MHonArc 2.6.16.