openscenegraph
ShadowMap
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGSHADOW_SHADOWEMAP
15#define OSGSHADOW_SHADOWEMAP 1
16
17#include <osg/Camera>
18#include <osg/Material>
19#include <osg/MatrixTransform>
20#include <osg/LightSource>
21
23
24namespace osgShadow {
25
28{
29 public :
31
33
35
37 void setTextureUnit(unsigned int unit);
38
40 unsigned int getTextureUnit() const { return _shadowTextureUnit; }
41
43 void setPolygonOffset(const osg::Vec2& polyOffset);
44
46 const osg::Vec2& getPolygonOffset() const { return _polyOffset; }
47
49 void setAmbientBias(const osg::Vec2& ambientBias );
50
52 const osg::Vec2& getAmbientBias() const { return _ambientBias; }
53
55 void setTextureSize(const osg::Vec2s& textureSize);
56
58 const osg::Vec2s& getTextureSize() const { return _textureSize; }
59
61 void setLight(osg::Light* light);
63
64 typedef std::vector< osg::ref_ptr<osg::Uniform> > UniformList;
65
66 typedef std::vector< osg::ref_ptr<osg::Shader> > ShaderList;
67
69 inline void addShader(osg::Shader* shader) { _shaderList.push_back(shader); }
70
71 template<class T> void addShader( const osg::ref_ptr<T>& shader ) { addShader(shader.get()); }
72
74 inline void clearShaderList() { _shaderList.clear(); }
75
77 virtual void init();
78
80 virtual void update(osg::NodeVisitor& nv);
81
83 virtual void cull(osgUtil::CullVisitor& cv);
84
86 virtual void cleanSceneGraph();
87
88
90 virtual void resizeGLObjectBuffers(unsigned int maxSize);
91
95 virtual void releaseGLObjects(osg::State* = 0) const;
96
97
98 // debug methods
99
101
102 protected:
103 virtual ~ShadowMap(void) {};
104
106 virtual void createUniforms();
107
108 virtual void createShaders();
109
110 // forward declare, interface and implementation provided in ShadowMap.cpp
111 class DrawableDrawWithDepthShadowComparisonOffCallback;
112
119
121
125 unsigned int _baseTextureUnit;
126 unsigned int _shadowTextureUnit;
130
131 };
132
133}
134
135#endif
Definition ShadowMap:28
META_Object(osgShadow, ShadowMap)
osg::ref_ptr< osg::Camera > makeDebugHUD()
osg::ref_ptr< osg::StateSet > _stateset
Definition ShadowMap:116
virtual void update(osg::NodeVisitor &nv)
osg::ref_ptr< osg::Program > _program
Definition ShadowMap:117
virtual void cull(osgUtil::CullVisitor &cv)
UniformList _uniformList
Definition ShadowMap:123
osg::Vec2 _ambientBias
Definition ShadowMap:128
osg::ref_ptr< osg::Light > _light
Definition ShadowMap:118
void addShader(const osg::ref_ptr< T > &shader)
Definition ShadowMap:71
void setTextureUnit(unsigned int unit)
void setLight(osg::Light *light)
virtual void init()
const osg::Vec2s & getTextureSize() const
Definition ShadowMap:58
osg::Vec2s _textureSize
Definition ShadowMap:129
unsigned int _baseTextureUnit
Definition ShadowMap:125
void setTextureSize(const osg::Vec2s &textureSize)
unsigned int getTextureUnit() const
Definition ShadowMap:40
virtual void cleanSceneGraph()
osg::ref_ptr< osg::Camera > _camera
Definition ShadowMap:113
void setAmbientBias(const osg::Vec2 &ambientBias)
osg::ref_ptr< osg::LightSource > _ls
Definition ShadowMap:120
osg::ref_ptr< osg::Uniform > _ambientBiasUniform
Definition ShadowMap:122
void clearShaderList()
Definition ShadowMap:74
virtual ~ShadowMap(void)
Definition ShadowMap:103
void setLight(osg::LightSource *ls)
virtual void createUniforms()
osg::Vec2 _polyOffset
Definition ShadowMap:127
virtual void resizeGLObjectBuffers(unsigned int maxSize)
void addShader(osg::Shader *shader)
Definition ShadowMap:69
ShaderList _shaderList
Definition ShadowMap:124
const osg::Vec2 & getAmbientBias() const
Definition ShadowMap:52
std::vector< osg::ref_ptr< osg::Shader > > ShaderList
Definition ShadowMap:66
osg::ref_ptr< osg::Texture2D > _texture
Definition ShadowMap:115
void setPolygonOffset(const osg::Vec2 &polyOffset)
osg::ref_ptr< osg::TexGen > _texgen
Definition ShadowMap:114
virtual void releaseGLObjects(osg::State *=0) const
ShadowMap(const ShadowMap &es, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
std::vector< osg::ref_ptr< osg::Uniform > > UniformList
Definition ShadowMap:64
unsigned int _shadowTextureUnit
Definition ShadowMap:126
const osg::Vec2 & getPolygonOffset() const
Definition ShadowMap:46
virtual void createShaders()
Definition ShadowTechnique:32
Definition CullVisitor:49
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition LightSource:25
Definition Light:40
Definition NodeVisitor:82
Definition Shader:89
Definition State:80
Definition Vec2f:29
Definition Vec2s:20
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Definition ConvexPolyhedron:33
#define OSGSHADOW_EXPORT
Definition osgShadow/Export:39