Added ShadowSettings::s/getMaximumShadowMapDistance(double) property, usage of these property in ViewDependentShadowMap,

and setting of it with --max-shadow-distance <double> in the osgshadow example.
This commit is contained in:
Robert Osfield
2012-08-15 12:40:48 +00:00
parent 52861ecbb0
commit 284f410436
4 changed files with 22 additions and 2 deletions

View File

@@ -12,6 +12,7 @@
*/
#include <osgShadow/ShadowSettings>
#include <float.h>
using namespace osgShadow;
@@ -24,6 +25,7 @@ ShadowSettings::ShadowSettings():
_useShadowMapTextureOverride(true),
_textureSize(2048,2048),
_minimumShadowMapNearFarRatio(0.05),
_maximumShadowMapDistance(DBL_MAX),
_shadowMapProjectionHint(PERSPECTIVE_SHADOW_MAP),
_perspectiveShadowMapCutOffAngle(2.0),
_numShadowMapsPerLight(1),
@@ -46,6 +48,7 @@ ShadowSettings::ShadowSettings(const ShadowSettings& ss, const osg::CopyOp& copy
_useShadowMapTextureOverride(ss._useShadowMapTextureOverride),
_textureSize(ss._textureSize),
_minimumShadowMapNearFarRatio(ss._minimumShadowMapNearFarRatio),
_maximumShadowMapDistance(ss._maximumShadowMapDistance),
_shadowMapProjectionHint(ss._shadowMapProjectionHint),
_perspectiveShadowMapCutOffAngle(ss._perspectiveShadowMapCutOffAngle),
_numShadowMapsPerLight(ss._numShadowMapsPerLight),

View File

@@ -799,9 +799,12 @@ void ViewDependentShadowMap::cull(osgUtil::CullVisitor& cv)
cv.computeNearPlane();
}
//minZNear = osg::maximum(10.0,minZNear);
//maxZFar = osg::minimum(60.0,maxZFar);
// clamp the minZNear and maxZFar to those provided by ShadowSettings
maxZFar = osg::minimum(settings->getMaximumShadowMapDistance(),maxZFar);
if (minZNear>maxZFar) minZNear = maxZFar*settings->getMinimumShadowMapNearFarRatio();
//OSG_NOTICE<<"maxZFar "<<maxZFar<<std::endl;
Frustum frustum(&cv, minZNear, maxZFar);
// return compute near far mode back to it's original settings