14 #include <osgEarth/VirtualProgram>
16 #include <osgShadow/ShadowTechnique>
18 #include <osg/StateSet>
20 #include <osg/PolygonOffset>
21 #include <osg/FrameBufferObject>
22 #include <osg/Uniform>
23 #include <osg/LightSource>
24 #include <osg/RenderInfo>
28 #include <osg/Program>
29 #include <osg/Texture2D>
30 #include <osg/Texture2DArray>
43 class DtShadowSettingsObject;
44 class TextureApplyAttribute;
71 virtual const char*
className()
const {
return "DtOsgShadowTechnique"; }
77 virtual void update(osg::NodeVisitor& nv);
80 virtual void cull(osgUtil::CullVisitor& cv);
83 virtual void cleanSceneGraph();
86 void setChannelShadowState(
DtOsgChannel* osgChannel,
bool enable);
92 bool getChannelCloudShadowMap(
DtOsgChannel* osgChannel,
unsigned int* textureIndex, osg::Matrix* textureViewProjMatrix);
95 bool getCameraCloudShadowMap(osg::Camera* camera,
unsigned int* textureIndex, osg::Matrix* textureViewProjMatrix);
103 static const std::string& shadowCameraPrefixString(
void);
104 static const std::string& shadowSDSMCameraPrefixString(
void);
108 virtual void reInitialize(
unsigned int quality);
110 virtual bool configureShadowTraversalNodeMask(
bool traverseEntities,
bool traverseProps,
bool traverseTerrain);
118 virtual void operator () (osg::RenderInfo& renderInfo)
const;
121 void enableBindFbo(
bool bind);
135 virtual void operator () (osg::RenderInfo& renderInfo)
const;
138 void setRestoreDrawBuffer(GLenum bufferAttachment);
141 void setRestoreReadBuffer(GLenum bufferAttachment);
144 void enableUnbindFbo(
bool unbind);
154 SdsmDrawCallback(
bool bindFbo, GLenum colorAttachment,
unsigned int numPipelines,
unsigned int numPartitions,
unsigned int width,
unsigned int height);
160 virtual void operator () (osg::RenderInfo& renderInfo)
const;
163 float minDepth()
const;
166 float maxDepth()
const;
169 float minDepth(
unsigned int splitIndex)
const;
172 float maxDepth(
unsigned int splitIndex)
const;
175 osg::Vec2 partition(
unsigned int splitIndex)
const;
178 bool isSDSMDepthAvailable()
const;
192 mutable float myMinDepthArray[20];
193 mutable float myMaxDepthArray[20];
205 virtual void operator () (osg::RenderInfo& renderInfo)
const;
244 , myAtlasWidthNumSplits(0)
245 , myAtlasHeightNumSplits(0)
246 , myJustInitialized(false)
247 , myNotInitialized(true)
299 virtual void operator () (osg::RenderInfo& renderInfo)
const;
361 void updateCloudShadows(osg::Camera* camera);
370 osg::Program* getProgramFromFile(
const std::string& szVertexShader,
const std::string& szFragmentShader);
374 osg::Camera* xBlurCamera, osg::Camera* yBlurCamera, osg::Texture2D* texture, osg::StateSet* stateSet,
unsigned int textureUnit);
378 osg::Camera* xBlurCamera, osg::Camera* yBlurCamera,
unsigned int textureLayer, osg::Texture2DArray* texture2DArray,
379 osg::Texture2DArray* preFilterTexture2DArray1, osg::Texture2DArray* preFilterTexture2DArray2);
382 osg::Texture2D* createTexture2D(
int width,
int height, GLenum internalFormat, GLenum sourceFormat, GLenum sourceType,
bool shadowComparisonMode,
383 osg::Texture2D::FilterMode minFilter = osg::Texture2D::NEAREST, osg::Texture2D::FilterMode magFilter = osg::Texture2D::NEAREST);
386 osg::Texture2DArray* createTexture2DArray(
int width,
int height,
int depth, GLenum internalFormat, GLenum sourceFormat, GLenum sourceType,
387 bool shadowComparisonMode, osg::Texture2DArray::FilterMode minFilter = osg::Texture2DArray::NEAREST, osg::Texture2DArray::FilterMode magFilter = osg::Texture2DArray::NEAREST);
390 osg::Camera* createCamera(
int width,
int height, GLbitfield clearMask);
393 osg::Geode* createFullScreenQuad(
const osg::Vec2& size,
const osg::Vec2& uvStart,
const osg::Vec2& uvStop);
396 osg::Camera* createHudCamera(
int width,
int height, GLbitfield clearMask);
399 double computeUniformSplit(
double nearDistance,
double farDistance,
unsigned int splitIndex,
unsigned int numSplits);
402 double computeLogarithmicSplit(
double nearDistance,
double farDistance,
unsigned int splitIndex,
unsigned int numSplits);
406 const osg::Matrix& cameraViewMatrix,
const osg::Matrix& cameraProjectionMatrix,
double cameraMagnification);