From 52c2bc3ff5186601f4957d06fb4879136868839e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 2 Sep 2011 10:16:16 +0000 Subject: [PATCH] Added s/getTextureSize() method for setting the shadow map texture size. --- include/osgShadow/ViewDependentShadowMap | 7 +++++++ src/osgShadow/ViewDependentShadowMap.cpp | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/osgShadow/ViewDependentShadowMap b/include/osgShadow/ViewDependentShadowMap index 8746e28dc..bebb5fa0f 100644 --- a/include/osgShadow/ViewDependentShadowMap +++ b/include/osgShadow/ViewDependentShadowMap @@ -159,6 +159,12 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique /** Get the texture unit that the first shadow map will be placed on.*/ unsigned int getBaseShadowTextureUnit() const { return _baseShadowTextureUnit; } + /** Set the size of the shadow map textures.*/ + void setTextureSize(const osg::Vec2s& textureSize) { _textureSize = textureSize; } + + /** Get the size of the shadow map textures.*/ + const osg::Vec2s& getTextureSize() const { return _textureSize; } + enum ShadowMapProjectionHint { ORTHOGRAPHIC_SHADOW_MAP, @@ -203,6 +209,7 @@ protected: ViewDependentDataMap _viewDependentDataMap; unsigned int _baseShadowTextureUnit; + osg::Vec2s _textureSize; osg::ref_ptr _shadowRecievingPlaceholderStateSet; diff --git a/src/osgShadow/ViewDependentShadowMap.cpp b/src/osgShadow/ViewDependentShadowMap.cpp index ff19f65ad..4e65a981d 100644 --- a/src/osgShadow/ViewDependentShadowMap.cpp +++ b/src/osgShadow/ViewDependentShadowMap.cpp @@ -293,9 +293,9 @@ ViewDependentShadowMap::ShadowData::ShadowData(ViewDependentShadowMap::ViewDepen // set up the texture _texture = new osg::Texture2D; - unsigned int textureSize = debug ? 512 : 2048; + osg::Vec2s textureSize = debug ? osg::Vec2s(512,512) : vdd->getViewDependentShadowMap()->getTextureSize(); + _texture->setTextureSize(textureSize.x(), textureSize.y()); - _texture->setTextureSize(textureSize, textureSize); if (debug) { _texture->setInternalFormat(GL_RGB); @@ -327,7 +327,7 @@ ViewDependentShadowMap::ShadowData::ShadowData(ViewDependentShadowMap::ViewDepen _camera->setComputeNearFarMode(osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); // set viewport - _camera->setViewport(0,0,textureSize,textureSize); + _camera->setViewport(0,0,textureSize.x(),textureSize.y()); if (debug) @@ -522,7 +522,8 @@ void ViewDependentShadowMap::ViewDependentData::releaseGLObjects(osg::State* sta // ViewDependentShadowMap::ViewDependentShadowMap(): ShadowTechnique(), - _baseShadowTextureUnit(1), + _baseShadowTextureUnit(1), + _textureSize(2048,2048), _shadowMapProjectionHint(PERSPECTIVE_SHADOW_MAP), _minimumShadowMapNearFarRatio(0.01), _debugDraw(false) @@ -533,6 +534,7 @@ ViewDependentShadowMap::ViewDependentShadowMap(): ViewDependentShadowMap::ViewDependentShadowMap(const ViewDependentShadowMap& vdsm, const osg::CopyOp& copyop): ShadowTechnique(vdsm,copyop), _baseShadowTextureUnit(vdsm._baseShadowTextureUnit), + _textureSize(vdsm._textureSize), _shadowMapProjectionHint(vdsm._shadowMapProjectionHint), _minimumShadowMapNearFarRatio(vdsm._minimumShadowMapNearFarRatio), _debugDraw(vdsm._debugDraw)