OpenSceneGraph 3.6.5
ViewDependentShadowMap
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2011 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_VIEWDEPENDENTSHADOWMAP
15#define OSGSHADOW_VIEWDEPENDENTSHADOWMAP 1
16
17#include <osg/Camera>
18#include <osg/Material>
19#include <osg/MatrixTransform>
20#include <osg/LightSource>
21#include <osg/PolygonOffset>
22
24
25namespace osgShadow {
26
29{
30 public :
32
34
36
38 virtual void init();
39
41 virtual void update(osg::NodeVisitor& nv);
42
44 virtual void cull(osgUtil::CullVisitor& cv);
45
47 virtual void resizeGLObjectBuffers(unsigned int maxSize);
48
52 virtual void releaseGLObjects(osg::State* = 0) const;
53
55 virtual void cleanSceneGraph();
56
57
59 {
60 Frustum(osgUtil::CullVisitor* cv, double minZNear, double maxZFar);
61
64
65 typedef std::vector<osg::Vec3d> Vertices;
67
68 typedef std::vector<unsigned int> Indices;
69 typedef std::vector<Indices> Faces;
71
72 typedef std::vector<Indices> Edges;
74
80 };
81
82 // forward declare
84
104
105 typedef std::list< osg::ref_ptr<LightData> > LightDataList;
106
120
121 typedef std::list< osg::ref_ptr<ShadowData> > ShadowDataList;
122
123
149
151
153
154
155
156 virtual void createShaders();
157
159
161
162 virtual bool computeShadowCameraSettings(Frustum& frustum, LightData& positionedLight, osg::Matrixd& projectionMatrix, osg::Matrixd& viewMatrix);
163
164 virtual bool adjustPerspectiveShadowMapCameraSettings(osgUtil::RenderStage* renderStage, Frustum& frustum, LightData& positionedLight, osg::Camera* camera);
165
166 virtual bool assignTexGenSettings(osgUtil::CullVisitor* cv, osg::Camera* camera, unsigned int textureUnit, osg::TexGen* texgen);
167
169
171
173
174protected:
176
177 typedef std::map< osgUtil::CullVisitor*, osg::ref_ptr<ViewDependentData> > ViewDependentDataMap;
178 mutable OpenThreads::Mutex _viewDependentDataMapMutex;
180
182
187
188 typedef std::vector< osg::ref_ptr<osg::Uniform> > Uniforms;
189 mutable OpenThreads::Mutex _accessUniformsAndProgramMutex;
192};
193
194}
195
196#endif
RefMatrixd RefMatrix
Definition Matrix:28
The osgShadow library is a NodeKit that extends the core scene graph to add support for a range of sh...
Definition ConvexPolyhedron:33
Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
Definition Camera:45
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
Definition Matrixd:27
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
A Polytope class for representing convex clipping volumes made up of a set of planes.
Definition Polytope:26
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Stores a set of modes and attributes which represent a set of OpenGL state.
Definition StateSet:46
TexGen encapsulates the OpenGL glTexGen (texture coordinate generation) state.
Definition TexGen:43
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
General purpose double quad.
Definition Vec4d:29
std::list< osg::ref_ptr< LightData > > LightDataList
Definition ViewDependentShadowMap:105
virtual void cleanSceneGraph()
Clean scene graph from any shadow technique specific nodes, state and drawables.
virtual bool computeShadowCameraSettings(Frustum &frustum, LightData &positionedLight, osg::Matrixd &projectionMatrix, osg::Matrixd &viewMatrix)
virtual bool adjustPerspectiveShadowMapCameraSettings(osgUtil::RenderStage *renderStage, Frustum &frustum, LightData &positionedLight, osg::Camera *camera)
META_Object(osgShadow, ViewDependentShadowMap)
ViewDependentShadowMap(const ViewDependentShadowMap &vdsm, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
std::list< osg::ref_ptr< ShadowData > > ShadowDataList
Definition ViewDependentShadowMap:121
ViewDependentDataMap _viewDependentDataMap
Definition ViewDependentShadowMap:179
ViewDependentData * getViewDependentData(osgUtil::CullVisitor *cv)
virtual osg::StateSet * selectStateSetForRenderingShadow(ViewDependentData &vdd) const
osg::ref_ptr< osg::StateSet > _shadowRecievingPlaceholderStateSet
Definition ViewDependentShadowMap:181
virtual osg::Polytope computeLightViewFrustumPolytope(Frustum &frustum, LightData &positionedLight)
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
Uniforms _uniforms
Definition ViewDependentShadowMap:190
osg::ref_ptr< osg::Texture2D > _fallbackShadowMapTexture
Definition ViewDependentShadowMap:186
virtual bool assignTexGenSettings(osgUtil::CullVisitor *cv, osg::Camera *camera, unsigned int textureUnit, osg::TexGen *texgen)
OpenThreads::Mutex _viewDependentDataMapMutex
Definition ViewDependentShadowMap:178
virtual void update(osg::NodeVisitor &nv)
run the update traversal of the ShadowedScene and update any loca chached data structures.
virtual void init()
initialize the ShadowedScene and local cached data structures.
osg::ref_ptr< osg::PolygonOffset > _polygonOffset
Definition ViewDependentShadowMap:184
OpenThreads::Mutex _accessUniformsAndProgramMutex
Definition ViewDependentShadowMap:189
virtual void cullShadowReceivingScene(osgUtil::CullVisitor *cv) const
osg::ref_ptr< osg::Program > _program
Definition ViewDependentShadowMap:191
virtual void releaseGLObjects(osg::State *=0) const
If State is non-zero, this function releases any associated OpenGL objects for the specified graphics...
osg::ref_ptr< osg::StateSet > _shadowCastingStateSet
Definition ViewDependentShadowMap:183
virtual ViewDependentData * createViewDependentData(osgUtil::CullVisitor *cv)
std::map< osgUtil::CullVisitor *, osg::ref_ptr< ViewDependentData > > ViewDependentDataMap
Definition ViewDependentShadowMap:177
virtual void cullShadowCastingScene(osgUtil::CullVisitor *cv, osg::Camera *camera) const
std::vector< osg::ref_ptr< osg::Uniform > > Uniforms
Definition ViewDependentShadowMap:188
osg::ref_ptr< osg::Texture2D > _fallbackBaseTexture
Definition ViewDependentShadowMap:185
virtual bool selectActiveLights(osgUtil::CullVisitor *cv, ViewDependentData *vdd) const
virtual void cull(osgUtil::CullVisitor &cv)
run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.
Definition ViewDependentShadowMap:59
std::vector< Indices > Edges
Definition ViewDependentShadowMap:72
Edges edges
Definition ViewDependentShadowMap:73
osg::Vec3d centerFarPlane
Definition ViewDependentShadowMap:77
Vertices corners
Definition ViewDependentShadowMap:66
Faces faces
Definition ViewDependentShadowMap:70
osg::Vec3d centerNearPlane
Definition ViewDependentShadowMap:76
std::vector< Indices > Faces
Definition ViewDependentShadowMap:69
osg::Matrixd projectionMatrix
Definition ViewDependentShadowMap:62
std::vector< osg::Vec3d > Vertices
Definition ViewDependentShadowMap:65
Frustum(osgUtil::CullVisitor *cv, double minZNear, double maxZFar)
osg::Matrixd modelViewMatrix
Definition ViewDependentShadowMap:63
osg::Vec3d frustumCenterLine
Definition ViewDependentShadowMap:79
std::vector< unsigned int > Indices
Definition ViewDependentShadowMap:68
osg::Vec3d center
Definition ViewDependentShadowMap:78
osg::Vec3d eye
Definition ViewDependentShadowMap:75
Definition ViewDependentShadowMap:86
std::vector< unsigned int > ActiveTextureUnits
Definition ViewDependentShadowMap:101
osg::Vec3d lightPos3
Definition ViewDependentShadowMap:97
osg::ref_ptr< const osg::Light > light
Definition ViewDependentShadowMap:94
bool directionalLight
Definition ViewDependentShadowMap:99
osg::Vec4d lightPos
Definition ViewDependentShadowMap:96
ActiveTextureUnits textureUnits
Definition ViewDependentShadowMap:102
ViewDependentData * _viewDependentData
Definition ViewDependentShadowMap:91
osg::Vec3d lightDir
Definition ViewDependentShadowMap:98
virtual void setLightData(osg::RefMatrix *lm, const osg::Light *l, const osg::Matrixd &modelViewMatrix)
osg::ref_ptr< osg::RefMatrix > lightMatrix
Definition ViewDependentShadowMap:93
osg::ref_ptr< osg::Camera > _camera
Definition ViewDependentShadowMap:118
osg::ref_ptr< osg::TexGen > _texgen
Definition ViewDependentShadowMap:117
unsigned int _textureUnit
Definition ViewDependentShadowMap:115
virtual void releaseGLObjects(osg::State *=0) const
ViewDependentData * _viewDependentData
Definition ViewDependentShadowMap:113
osg::ref_ptr< osg::Texture2D > _texture
Definition ViewDependentShadowMap:116
Definition ViewDependentShadowMap:125
ShadowDataList & getShadowDataList()
Definition ViewDependentShadowMap:133
LightDataList _lightDataList
Definition ViewDependentShadowMap:146
ShadowDataList _shadowDataList
Definition ViewDependentShadowMap:147
const ViewDependentShadowMap * getViewDependentShadowMap() const
Definition ViewDependentShadowMap:129
virtual ~ViewDependentData()
Definition ViewDependentShadowMap:140
ViewDependentShadowMap * _viewDependentShadowMap
Definition ViewDependentShadowMap:142
osg::ref_ptr< osg::StateSet > _stateset
Definition ViewDependentShadowMap:144
virtual void releaseGLObjects(osg::State *=0) const
osg::StateSet * getStateSet()
Definition ViewDependentShadowMap:135
LightDataList & getLightDataList()
Definition ViewDependentShadowMap:131
Basic NodeVisitor implementation for rendering a scene.
Definition CullVisitor:49
RenderStage base class.
Definition RenderStage:38
#define OSGSHADOW_EXPORT
Definition Export:39

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