OpenSceneGraph 3.6.5
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
Vec2f Vec2
Definition Vec2:21
The osgShadow library is a NodeKit that extends the core scene graph to add support for a range of sh...
Definition ConvexPolyhedron:33
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Light state class which encapsulates OpenGL glLight() functionality.
Definition Light:40
Leaf Node for defining a light in the scene.
Definition LightSource:25
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
osg::Shader is an application-level abstraction of an OpenGL glShader.
Definition Shader:89
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Definition Vec2s:20
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)
run the update traversal of the ShadowedScene and update any loca chached data structures.
osg::ref_ptr< osg::Program > _program
Definition ShadowMap:117
virtual void cull(osgUtil::CullVisitor &cv)
run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.
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)
Set the texture unit that the shadow texture will be applied on.
void setLight(osg::Light *light)
Set the Light that will cast shadows.
virtual void init()
initialize the ShadowedScene and local cached data structures.
const osg::Vec2s & getTextureSize() const
Get the values that are used for the ambient bias in the shader.
Definition ShadowMap:58
osg::Vec2s _textureSize
Definition ShadowMap:129
unsigned int _baseTextureUnit
Definition ShadowMap:125
void setTextureSize(const osg::Vec2s &textureSize)
set the size in pixels x / y for the shadow texture.
unsigned int getTextureUnit() const
Get the texture unit that the shadow texture will be applied on.
Definition ShadowMap:40
virtual void cleanSceneGraph()
Clean scene graph from any shadow technique specific nodes, state and drawables.
osg::ref_ptr< osg::Camera > _camera
Definition ShadowMap:113
void setAmbientBias(const osg::Vec2 &ambientBias)
Set the values for the ambient bias the shader will use.
osg::ref_ptr< osg::LightSource > _ls
Definition ShadowMap:120
osg::ref_ptr< osg::Uniform > _ambientBiasUniform
Definition ShadowMap:122
void clearShaderList()
Reset internal shader list.
Definition ShadowMap:74
virtual ~ShadowMap(void)
Definition ShadowMap:103
void setLight(osg::LightSource *ls)
virtual void createUniforms()
Create the managed Uniforms.
osg::Vec2 _polyOffset
Definition ShadowMap:127
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
void addShader(osg::Shader *shader)
Add a shader to internal list, will be used instead of the default ones.
Definition ShadowMap:69
ShaderList _shaderList
Definition ShadowMap:124
const osg::Vec2 & getAmbientBias() const
Get the values that are used for the ambient bias in the shader.
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)
set the polygon offset used initially
osg::ref_ptr< osg::TexGen > _texgen
Definition ShadowMap:114
virtual void releaseGLObjects(osg::State *=0) const
If State is non-zero, this function releases any associated OpenGL objects for the specified graphics...
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
get the used polygon offset
Definition ShadowMap:46
virtual void createShaders()
Basic NodeVisitor implementation for rendering a scene.
Definition CullVisitor:49
#define OSGSHADOW_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.