From 771075084b3c37db6dbbce2b9c1395ef22fe9fed Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 26 Aug 2011 15:40:09 +0000 Subject: [PATCH] Fixed bug in computaton of the min/max x/z ratios. --- src/osgShadow/ViewDependentShadowMap.cpp | 40 +++++++++++++++--------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/osgShadow/ViewDependentShadowMap.cpp b/src/osgShadow/ViewDependentShadowMap.cpp index bddaa6e0a..04b7d1c83 100644 --- a/src/osgShadow/ViewDependentShadowMap.cpp +++ b/src/osgShadow/ViewDependentShadowMap.cpp @@ -151,6 +151,7 @@ void VDSMCameraCullCallback::operator()(osg::Node* node, osg::NodeVisitor* nv) osg::Camera* camera = dynamic_cast(node); OSG_INFO<<"VDSMCameraCullCallback::operator()(osg::Node* "<pushCullingSet(); } - +#endif if (_vdsm->getShadowedScene()) { _vdsm->getShadowedScene()->osg::Group::traverse(*nv); } - +#if 1 if (!_polytope.empty()) { OSG_INFO<<"Popping custom Polytope"<popCullingSet(); } +#endif - _renderStage = cv->getRenderStage(); + _renderStage = cv->getCurrentRenderBin()->getStage(); - if (cv->getComputeNearFarMode() != osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR) + OSG_INFO<<"VDSM second : _renderStage = "<<_renderStage<getComputeNearFarMode() != osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR) { // make sure that the near plane is computed correctly. cv->computeNearPlane(); @@ -776,7 +780,9 @@ bool ViewDependentShadowMap::selectActiveLights(osgUtil::CullVisitor* cv, ViewDe previous_ldl.swap(pll); //MR testing giving a specific light - osgUtil::RenderStage * rs = cv->getRenderStage(); + osgUtil::RenderStage * rs = cv->getCurrentRenderBin()->getStage(); + + OSG_INFO<<"selectActiveLights osgUtil::RenderStage="<getModelViewMatrix()); @@ -1357,16 +1363,17 @@ struct RenderLeafBounds { previous_modelview = renderLeaf->_modelview.get(); light_mvp.mult(*renderLeaf->_modelview, light_vp); - //OSG_NOTICE<<"Computing new light_mvp "<_drawable->getBound(); if (bb.valid()) { + OSG_INFO<<"checked extents of "<_drawable->getName()<n) { @@ -1420,6 +1426,7 @@ struct RenderLeafBounds if (ls.y()>max_y) max_y=ls.y(); if (ls.z()max_z) max_z=ls.z(); + } unsigned int numRenderLeaf; @@ -1509,6 +1516,8 @@ bool ViewDependentShadowMap::adjustPerspectiveShadowMapCameraSettings(osgUtil::R double zMin = osg::maximum(-1.0,convexHull.min(2)); double zMax = osg::minimum(1.0,convexHull.max(2)); + // we always want the lightspace to include the computed near plane. + zMin = -1.0; if (xMin!=-1.0 || yMin!=-1.0 || zMin!=-1.0 || xMax!=1.0 || yMax!=1.0 || zMax!=1.0) { @@ -1530,7 +1539,6 @@ bool ViewDependentShadowMap::adjustPerspectiveShadowMapCameraSettings(osgUtil::R convexHull.output(osg::notify(osg::NOTICE)); #endif camera->setProjectionMatrix(light_p); - //return true; } osg::Vec3d eye_v = frustum.eye * light_v; @@ -1596,10 +1604,10 @@ bool ViewDependentShadowMap::adjustPerspectiveShadowMapCameraSettings(osgUtil::R osg::Matrixd lightView; lightView.makeLookAt(virtual_eye, virtual_eye+lightdir, up); -#if 0 +#if 0 OSG_NOTICE<<"n = "<