OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShadowMap.h
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 
22 #include <osgShadow/ShadowTechnique>
23 
24 namespace osgShadow {
25 
28 {
29  public :
30  ShadowMap();
31 
32  ShadowMap(const ShadowMap& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
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);
62  void setLight(osg::LightSource* ls);
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 
72  inline void clearShaderList() { _shaderList.clear(); }
73 
75  virtual void init();
76 
78  virtual void update(osg::NodeVisitor& nv);
79 
81  virtual void cull(osgUtil::CullVisitor& cv);
82 
84  virtual void cleanSceneGraph();
85 
86  // debug methods
87 
88  osg::ref_ptr<osg::Camera> makeDebugHUD();
89 
90  protected:
91  virtual ~ShadowMap(void) {};
92 
94  virtual void createUniforms();
95 
96  virtual void createShaders();
97 
98  // forward declare, interface and implementation provided in ShadowMap.cpp
99  class DrawableDrawWithDepthShadowComparisonOffCallback;
100 
107 
109 
111  UniformList _uniformList;
112  ShaderList _shaderList;
113  unsigned int _baseTextureUnit;
114  unsigned int _shadowTextureUnit;
118 
119  };
120 
121 }
122 
123 #endif
ShaderList _shaderList
Definition: ShadowMap.h:112
osg::ref_ptr< osg::Uniform > _ambientBiasUniform
Definition: ShadowMap.h:110
std::vector< osg::ref_ptr< osg::Shader > > ShaderList
Definition: ShadowMap.h:66
std::vector< osg::ref_ptr< osg::Uniform > > UniformList
Definition: ShadowMap.h:64
const osg::Vec2s & getTextureSize() const
Definition: ShadowMap.h:58
UniformList _uniformList
Definition: ShadowMap.h:111
osg::Vec2s _textureSize
Definition: ShadowMap.h:117
osg::ref_ptr< osg::Light > _light
Definition: ShadowMap.h:106
const osg::Vec2 & getPolygonOffset() const
Definition: ShadowMap.h:46
unsigned int _shadowTextureUnit
Definition: ShadowMap.h:114
const osg::Vec2 & getAmbientBias() const
Definition: ShadowMap.h:52
unsigned int getTextureUnit() const
Definition: ShadowMap.h:40
#define OSGSHADOW_EXPORT
Definition: Export.h:39
osg::ref_ptr< osg::Texture2D > _texture
Definition: ShadowMap.h:103
#define META_Object(library, name)
Definition: Object.h:42
osg::Vec2 _polyOffset
Definition: ShadowMap.h:115
osg::Vec2 _ambientBias
Definition: ShadowMap.h:116
void addShader(osg::Shader *shader)
Definition: ShadowMap.h:69
osg::ref_ptr< osg::TexGen > _texgen
Definition: ShadowMap.h:102
osg::ref_ptr< osg::LightSource > _ls
Definition: ShadowMap.h:108
virtual ~ShadowMap(void)
Definition: ShadowMap.h:91
unsigned int _baseTextureUnit
Definition: ShadowMap.h:113
void clearShaderList()
Definition: ShadowMap.h:72
osg::ref_ptr< osg::Program > _program
Definition: ShadowMap.h:105
osg::ref_ptr< osg::StateSet > _stateset
Definition: ShadowMap.h:104
osg::ref_ptr< osg::Camera > _camera
Definition: ShadowMap.h:99