OpenSceneGraph 3.6.5
MinimalShadowMap
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 * ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
14 * Thanks to to my company http://www.ai.com.pl for allowing me free this work.
15*/
16
17#ifndef OSGSHADOW_MINIMALSHADOWMAP
18#define OSGSHADOW_MINIMALSHADOWMAP 1
19
21
22namespace osgShadow {
23
25{
26 public :
31
34
37 const MinimalShadowMap& msm,
39
42
43 void setModellingSpaceToWorldTransform( const osg::Matrix & modellingSpaceToWorld )
44 { _modellingSpaceToWorld = modellingSpaceToWorld; }
45
48
49 float getMaxFarPlane( ) const
50 { return _maxFarPlane; }
51
52 void setMaxFarPlane( float maxFarPlane )
53 { _maxFarPlane = maxFarPlane; }
54
55 float getMinLightMargin( ) const
56 { return _minLightMargin; }
57
58 void setMinLightMargin( float minLightMargin )
59 { _minLightMargin = minLightMargin; }
60
67
71
72 ShadowReceivingCoarseBoundAccuracy
75
76 protected:
78 virtual ~MinimalShadowMap(void);
79
80 protected:
81 // Matrix modellingSpaceToWorld and its inverse
82 // are used to define Modelling Space where shadowed scene drawables
83 // have minimal (smallest possible extent) bounding boxes.
84
85 // Computing visible shadow range in this space
86 // allows for optimal use of ShadowMap resolution.
87
88 // By default it is set to identity ie computations are in world space.
89 // But it should be set to ElipsoidModel::localToWorld
90 // when scene objects are put on earth ellipsoid surface.
91
92 // Other scenarios are also possible for example when models are
93 // built in XZY space which would require identity matrix with swapped columns
94
99
101 {
106
108 std::vector< osg::Vec3d > _sceneReceivingShadowPolytopePoints;
109
111
112 virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
113
115
117
119 const osg::BoundingSphere &bounds,
120 const osg::Light *light,
121 const osg::Vec4 &worldLightPos,
122 const osg::Vec3 &worldLightDir,
123 const osg::Vec3 &worldLightUp = osg::Vec3(0,1,0) );
124
125 virtual void aimShadowCastingCamera( const osg::Light *light,
126 const osg::Vec4 &worldLightPos,
127 const osg::Vec3 &worldLightDir,
128 const osg::Vec3 &worldLightUp
129 = osg::Vec3(0,1,0) );
130
132 ( const osg::Camera* cameraMain, osg::Camera* cameraShadow, int pass = 1 );
133
134 void cutScenePolytope( const osg::Matrix & matrix,
135 const osg::Matrix & inverse,
136 const osg::BoundingBox &bb =
137 osg::BoundingBox(-1,-1,-1,1,1,1) );
138
141
142 // Utility methods for adjusting projection matrices
143
144 // Modify projection matrix so that some output subrange
145 // is remapped to whole clip space (-1..1,-1..1,-1..1).
146 // Bit mask can be used to limit remaping to selected bounds only.
147 static void trimProjection
148 ( osg::Matrixd & projection, osg::BoundingBox subrange,
149 unsigned int trimMask = (1|2|4|8|16|32)
150 /*1=left|2=right|4=bottom|8=top|16=near|32=far*/);
151
152 static void clampProjection
153 ( osg::Matrixd & projection, float n = 0, float f = FLT_MAX );
154
156 ( osg::Matrixd & projection, osg::Viewport * viewport, const osg::Vec2& margin );
157 };
158
160};
161
162} // namespace osgShadow
163
164#endif
#define META_ViewDependentShadowTechniqueData(ShadowTechnique, TechniqueData)
META_ViewDependentShadowTechniqueData macro defines initViewDependentData method used by derived shad...
Definition ViewDependentShadowTechnique:32
Vec2f Vec2
Definition Vec2:21
Vec3f Vec3
Definition Vec3:21
BoundingBoxd BoundingBox
Definition BoundingBox:257
BoundingSphered BoundingSphere
Definition BoundingSphere:308
Matrixd Matrix
Definition Matrix:27
Vec4f Vec4
Definition Vec4:21
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
Encapsulate OpenGL glViewport.
Definition Viewport:24
Definition ConvexPolyhedron:36
MinimalShadowMap(const MinimalShadowMap &msm, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Classic OSG cloning constructor.
const osg::Matrix & getModellingSpaceToWorldTransform(void) const
Definition MinimalShadowMap:46
StandardShadowMap BaseClass
Convenient typedef used in definition of ViewData struct and methods.
Definition MinimalShadowMap:30
ShadowReceivingCoarseBoundAccuracy _shadowReceivingCoarseBoundAccuracy
Definition MinimalShadowMap:98
void setMaxFarPlane(float maxFarPlane)
Definition MinimalShadowMap:52
virtual ~MinimalShadowMap(void)
Classic protected OSG destructor.
ShadowReceivingCoarseBoundAccuracy getShadowReceivingCoarseBoundAccuracy() const
Definition MinimalShadowMap:73
void setMinLightMargin(float minLightMargin)
Definition MinimalShadowMap:58
float _minLightMargin
Definition MinimalShadowMap:97
float _maxFarPlane
Definition MinimalShadowMap:96
ShadowReceivingCoarseBoundAccuracy
Definition MinimalShadowMap:61
@ BOUNDING_BOX
Definition MinimalShadowMap:64
@ EMPTY_BOX
Definition MinimalShadowMap:62
@ DEFAULT_ACCURACY
Definition MinimalShadowMap:65
@ BOUNDING_SPHERE
Definition MinimalShadowMap:63
MinimalShadowMap()
Classic OSG constructor.
float getMinLightMargin() const
Definition MinimalShadowMap:55
void setShadowReceivingCoarseBoundAccuracy(ShadowReceivingCoarseBoundAccuracy accuracy)
Definition MinimalShadowMap:69
osg::Matrix _modellingSpaceToWorld
Definition MinimalShadowMap:95
META_Object(osgShadow, MinimalShadowMap)
Declaration of standard OSG object methods.
void setModellingSpaceToWorldTransform(const osg::Matrix &modellingSpaceToWorld)
Definition MinimalShadowMap:43
MinimalShadowMap ThisClass
Convenient typedef used in definition of ViewData struct and methods.
Definition MinimalShadowMap:28
float getMaxFarPlane() const
Definition MinimalShadowMap:49
Definition MinimalShadowMap:101
osg::Matrixd _clampedProjection
Definition MinimalShadowMap:110
osg::Matrix * _modellingSpaceToWorldPtr
Definition MinimalShadowMap:102
virtual void aimShadowCastingCamera(const osg::BoundingSphere &bounds, const osg::Light *light, const osg::Vec4 &worldLightPos, const osg::Vec3 &worldLightDir, const osg::Vec3 &worldLightUp=osg::Vec3(0, 1, 0))
int _frameShadowCastingCameraPasses
Definition MinimalShadowMap:105
osg::BoundingBox computeScenePolytopeBounds(const osg::Matrix &m)
ConvexPolyhedron _sceneReceivingShadowPolytope
Definition MinimalShadowMap:107
static void extendProjection(osg::Matrixd &projection, osg::Viewport *viewport, const osg::Vec2 &margin)
virtual void init(ThisClass *st, osgUtil::CullVisitor *cv)
float * _maxFarPlanePtr
Definition MinimalShadowMap:103
osg::BoundingBox computeScenePolytopeBounds()
std::vector< osg::Vec3d > _sceneReceivingShadowPolytopePoints
Definition MinimalShadowMap:108
virtual osg::BoundingBox computeShadowReceivingCoarseBounds()
virtual void frameShadowCastingCamera(const osg::Camera *cameraMain, osg::Camera *cameraShadow, int pass=1)
float * _minLightMarginPtr
Definition MinimalShadowMap:104
static void clampProjection(osg::Matrixd &projection, float n=0, float f=FLT_MAX)
void cutScenePolytope(const osg::Matrix &matrix, const osg::Matrix &inverse, const osg::BoundingBox &bb=osg::BoundingBox(-1,-1,-1, 1, 1, 1))
virtual void aimShadowCastingCamera(const osg::Light *light, const osg::Vec4 &worldLightPos, const osg::Vec3 &worldLightDir, const osg::Vec3 &worldLightUp=osg::Vec3(0, 1, 0))
static void trimProjection(osg::Matrixd &projection, osg::BoundingBox subrange, unsigned int trimMask=(1|2|4|8|16|32))
StandardShadowMap()
Classic OSG constructor.
Definition StandardShadowMap:161
Basic NodeVisitor implementation for rendering a scene.
Definition CullVisitor:49
#define OSGSHADOW_EXPORT
Definition Export:39

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.