ShadowMap
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGSHADOW_SHADOWEMAP
#define OSGSHADOW_SHADOWEMAP 1
#include <osg/Camera>
#include <osg/Material>
#include <osg/MatrixTransform>
#include <osg/LightSource>
#include <osgShadow/ShadowTechnique>
namespace osgShadow {
class OSGSHADOW_EXPORT ShadowMap : public ShadowTechnique
{
public :
ShadowMap();
ShadowMap(const ShadowMap& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgShadow, ShadowMap);
void setTextureUnit(unsigned int unit);
unsigned int getTextureUnit() const { return _shadowTextureUnit; }
void setPolygonOffset(const osg::Vec2& polyOffset);
const osg::Vec2& getPolygonOffset() const { return _polyOffset; }
void setAmbientBias(const osg::Vec2& ambientBias );
const osg::Vec2& getAmbientBias() const { return _ambientBias; }
void setTextureSize(const osg::Vec2s& textureSize);
const osg::Vec2s& getTextureSize() const { return _textureSize; }
void setLight(osg::Light* light);
void setLight(osg::LightSource* ls);
typedef std::vector< osg::ref_ptr<osg::Uniform> > UniformList;
typedef std::vector< osg::ref_ptr<osg::Shader> > ShaderList;
inline void addShader(osg::Shader* shader) { _shaderList.push_back(shader); }
template<class T> void addShader( const osg::ref_ptr<T>& shader ) { addShader(shader.get()); }
inline void clearShaderList() { _shaderList.clear(); }
virtual void init();
virtual void update(osg::NodeVisitor& nv);
virtual void cull(osgUtil::CullVisitor& cv);
virtual void cleanSceneGraph();
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* = 0) const;
// debug methods
osg::ref_ptr<osg::Camera> makeDebugHUD();
protected:
virtual ~ShadowMap(void) {};
virtual void createUniforms();
virtual void createShaders();
// forward declare, interface and implementation provided in ShadowMap.cpp
class DrawableDrawWithDepthShadowComparisonOffCallback;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::TexGen> _texgen;
osg::ref_ptr<osg::Texture2D> _texture;
osg::ref_ptr<osg::StateSet> _stateset;
osg::ref_ptr<osg::Program> _program;
osg::ref_ptr<osg::Light> _light;
osg::ref_ptr<osg::LightSource> _ls;
osg::ref_ptr<osg::Uniform> _ambientBiasUniform;
UniformList _uniformList;
ShaderList _shaderList;
unsigned int _baseTextureUnit;
unsigned int _shadowTextureUnit;
osg::Vec2 _polyOffset;
osg::Vec2 _ambientBias;
osg::Vec2s _textureSize;
};
}
#endif
Camera
LightSource
Material
MatrixTransform
ShadowTechnique
osgShadow::ShadowMap::META_Object
META_Object(osgShadow, ShadowMap)
osgShadow::ShadowMap::makeDebugHUD
osg::ref_ptr< osg::Camera > makeDebugHUD()
osgShadow::ShadowMap::_stateset
osg::ref_ptr< osg::StateSet > _stateset
Definition ShadowMap:116
osgShadow::ShadowMap::update
virtual void update(osg::NodeVisitor &nv)
osgShadow::ShadowMap::_program
osg::ref_ptr< osg::Program > _program
Definition ShadowMap:117
osgShadow::ShadowMap::ShadowMap
ShadowMap()
osgShadow::ShadowMap::cull
virtual void cull(osgUtil::CullVisitor &cv)
osgShadow::ShadowMap::_uniformList
UniformList _uniformList
Definition ShadowMap:123
osgShadow::ShadowMap::_ambientBias
osg::Vec2 _ambientBias
Definition ShadowMap:128
osgShadow::ShadowMap::_light
osg::ref_ptr< osg::Light > _light
Definition ShadowMap:118
osgShadow::ShadowMap::addShader
void addShader(const osg::ref_ptr< T > &shader)
Definition ShadowMap:71
osgShadow::ShadowMap::setTextureUnit
void setTextureUnit(unsigned int unit)
osgShadow::ShadowMap::setLight
void setLight(osg::Light *light)
osgShadow::ShadowMap::init
virtual void init()
osgShadow::ShadowMap::getTextureSize
const osg::Vec2s & getTextureSize() const
Definition ShadowMap:58
osgShadow::ShadowMap::_textureSize
osg::Vec2s _textureSize
Definition ShadowMap:129
osgShadow::ShadowMap::_baseTextureUnit
unsigned int _baseTextureUnit
Definition ShadowMap:125
osgShadow::ShadowMap::setTextureSize
void setTextureSize(const osg::Vec2s &textureSize)
osgShadow::ShadowMap::getTextureUnit
unsigned int getTextureUnit() const
Definition ShadowMap:40
osgShadow::ShadowMap::cleanSceneGraph
virtual void cleanSceneGraph()
osgShadow::ShadowMap::_camera
osg::ref_ptr< osg::Camera > _camera
Definition ShadowMap:113
osgShadow::ShadowMap::setAmbientBias
void setAmbientBias(const osg::Vec2 &ambientBias)
osgShadow::ShadowMap::_ls
osg::ref_ptr< osg::LightSource > _ls
Definition ShadowMap:120
osgShadow::ShadowMap::_ambientBiasUniform
osg::ref_ptr< osg::Uniform > _ambientBiasUniform
Definition ShadowMap:122
osgShadow::ShadowMap::clearShaderList
void clearShaderList()
Definition ShadowMap:74
osgShadow::ShadowMap::~ShadowMap
virtual ~ShadowMap(void)
Definition ShadowMap:103
osgShadow::ShadowMap::setLight
void setLight(osg::LightSource *ls)
osgShadow::ShadowMap::createUniforms
virtual void createUniforms()
osgShadow::ShadowMap::_polyOffset
osg::Vec2 _polyOffset
Definition ShadowMap:127
osgShadow::ShadowMap::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osgShadow::ShadowMap::addShader
void addShader(osg::Shader *shader)
Definition ShadowMap:69
osgShadow::ShadowMap::_shaderList
ShaderList _shaderList
Definition ShadowMap:124
osgShadow::ShadowMap::getAmbientBias
const osg::Vec2 & getAmbientBias() const
Definition ShadowMap:52
osgShadow::ShadowMap::ShaderList
std::vector< osg::ref_ptr< osg::Shader > > ShaderList
Definition ShadowMap:66
osgShadow::ShadowMap::_texture
osg::ref_ptr< osg::Texture2D > _texture
Definition ShadowMap:115
osgShadow::ShadowMap::setPolygonOffset
void setPolygonOffset(const osg::Vec2 &polyOffset)
osgShadow::ShadowMap::_texgen
osg::ref_ptr< osg::TexGen > _texgen
Definition ShadowMap:114
osgShadow::ShadowMap::releaseGLObjects
virtual void releaseGLObjects(osg::State *=0) const
osgShadow::ShadowMap::ShadowMap
ShadowMap(const ShadowMap &es, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgShadow::ShadowMap::UniformList
std::vector< osg::ref_ptr< osg::Uniform > > UniformList
Definition ShadowMap:64
osgShadow::ShadowMap::_shadowTextureUnit
unsigned int _shadowTextureUnit
Definition ShadowMap:126
osgShadow::ShadowMap::getPolygonOffset
const osg::Vec2 & getPolygonOffset() const
Definition ShadowMap:46
osgShadow::ShadowMap::createShaders
virtual void createShaders()
osgShadow::ShadowTechnique::ShadowTechnique
ShadowTechnique()
osgUtil::CullVisitor
Definition CullVisitor:49
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::LightSource
Definition LightSource:25
osg::Light
Definition Light:40
osg::NodeVisitor
Definition NodeVisitor:82
osg::Shader
Definition Shader:89
osg::State
Definition State:80
osg::Vec2s
Definition Vec2s:20
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osgShadow
Definition ConvexPolyhedron:33
osg::Vec2
Vec2f Vec2
Definition Vec2:21
OSGSHADOW_EXPORT
#define OSGSHADOW_EXPORT
Definition osgShadow/Export:39