15 #include <osgEarth/VirtualProgram>
17 #include <osgShadow/ShadowTechnique>
19 #include <osg/StateSet>
21 #include <osg/PolygonOffset>
22 #include <osg/FrameBufferObject>
23 #include <osg/Uniform>
24 #include <osg/LightSource>
25 #include <osg/RenderInfo>
29 #include <osg/Program>
30 #include <osg/Texture2D>
31 #include <osg/Texture2DArray>
44 class DtShadowSettingsObject;
45 class TextureApplyAttribute;
72 virtual const char*
className()
const {
return "DtOsgShadowTechnique"; }
78 virtual void update(osg::NodeVisitor& nv);
81 virtual void cull(osgUtil::CullVisitor& cv);
84 virtual void cleanSceneGraph();
87 void setChannelShadowState(
DtOsgChannel* osgChannel,
bool enable);
93 bool getChannelCloudShadowMap(
DtOsgChannel* osgChannel,
unsigned int* textureIndex, osg::Matrix* textureViewProjMatrix);
96 bool getCameraCloudShadowMap(osg::Camera* camera,
unsigned int* textureIndex, osg::Matrix* textureViewProjMatrix);
104 static const std::string& shadowCameraPrefixString(
void);
105 static const std::string& shadowSDSMCameraPrefixString(
void);
109 virtual void reInitialize(
unsigned int quality);
111 virtual bool configureShadowTraversalNodeMask(
bool traverseEntities,
bool traverseProps,
bool traverseTerrain);
151 , myAtlasWidthNumSplits(0)
152 , myAtlasHeightNumSplits(0)
153 , myJustInitialized(false)
154 , myNotInitialized(true)
206 virtual void operator () (osg::RenderInfo& renderInfo)
const;
228 virtual osg::Matrixd oglRevDepthOrtho(
double left,
double right,
double bottom,
229 double top,
double zNear,
double zFar);
234 virtual bool getRevZProjectionMatrixAsFrustum(
const osg::Matrix& mat,
double& left,
235 double& right,
double& bottom,
double& top,
double& zNear,
double& zFar);
240 virtual bool getRevPerspective(
const osg::Matrix& mat,
double& fovy,
241 double& aspectRatio,
double& zNear,
double& zFar);
246 virtual osg::Matrix makeRevFrustum(
double left,
double right,
247 double bottom,
double top,
double zNear,
double zFar);
252 virtual osg::Matrix makeRevPerspective(
double fovy,
double aspectRatio,
253 double zNear,
double zFar);
297 void updateCloudShadows(osg::Camera* camera);
306 osg::Program* getProgramFromFile(
const std::string& szVertexShader,
const std::string& szFragmentShader);
310 osg::Camera* xBlurCamera, osg::Camera* yBlurCamera, osg::Texture2D* texture, osg::StateSet* stateSet,
unsigned int textureUnit);
314 osg::Camera* xBlurCamera, osg::Camera* yBlurCamera,
unsigned int textureLayer, osg::Texture2DArray* texture2DArray,
315 osg::Texture2DArray* preFilterTexture2DArray1, osg::Texture2DArray* preFilterTexture2DArray2);
318 osg::Texture2D* createTexture2D(
int width,
int height, GLenum internalFormat, GLenum sourceFormat, GLenum sourceType,
bool shadowComparisonMode,
319 osg::Texture2D::FilterMode minFilter = osg::Texture2D::NEAREST, osg::Texture2D::FilterMode magFilter = osg::Texture2D::NEAREST);
322 osg::Texture2DArray* createTexture2DArray(
int width,
int height,
int depth, GLenum internalFormat, GLenum sourceFormat, GLenum sourceType,
323 bool shadowComparisonMode, osg::Texture2DArray::FilterMode minFilter = osg::Texture2DArray::NEAREST, osg::Texture2DArray::FilterMode magFilter = osg::Texture2DArray::NEAREST);
326 osg::Camera* createCamera(
int width,
int height, GLbitfield clearMask);
329 osg::Geode* createFullScreenQuad(
const osg::Vec2&
size,
const osg::Vec2& uvStart,
const osg::Vec2& uvStop);
332 osg::Camera* createHudCamera(
int width,
int height, GLbitfield clearMask);
335 double computeUniformSplit(
double nearDistance,
double farDistance,
unsigned int splitIndex,
unsigned int numSplits);
338 double computeLogarithmicSplit(
double nearDistance,
double farDistance,
unsigned int splitIndex,
unsigned int numSplits);
342 const osg::Matrix& cameraViewMatrix,
const osg::Matrix& cameraProjectionMatrix,
double cameraMagnification);