From b32d8e01516d50cf28c33eb54bf80c79e7b7846a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 28 Sep 2011 10:54:30 +0000 Subject: [PATCH] Added computation of the extents, in light space, of the shadow maps RenderStage contents and use of this to produce a tighter bound light space projection. --- src/osgShadow/ViewDependentShadowMap.cpp | 113 +++++++++++++++++------ 1 file changed, 85 insertions(+), 28 deletions(-) diff --git a/src/osgShadow/ViewDependentShadowMap.cpp b/src/osgShadow/ViewDependentShadowMap.cpp index 352075fb9..984830306 100644 --- a/src/osgShadow/ViewDependentShadowMap.cpp +++ b/src/osgShadow/ViewDependentShadowMap.cpp @@ -1383,6 +1383,7 @@ struct ConvexHull struct RenderLeafBounds { RenderLeafBounds(): + computeRatios(false), numRenderLeaf(0), n(0.0), previous_modelview(0), @@ -1400,9 +1401,22 @@ struct RenderLeafBounds //OSG_NOTICE<_modelview.get(); if (previous_modelview) { - light_mvp.mult(*renderLeaf->_modelview, light_vp); + light_mvp.mult(*renderLeaf->_modelview, light_p); } else { // no modelview matrix (such as when LightPointNode is in the scene graph) so assume // that modelview matrix is indentity. - light_mvp = light_vp; + light_mvp = light_p; } - OSG_INFO<<"Computing new light_mvp "<_drawable->getBound(); if (bb.valid()) { - OSG_INFO<<"checked extents of "<_drawable->getName()<_drawable->getName()<n) - { - x_ratio = delta.x()/delta.y(); - z_ratio = delta.z()/delta.y(); - } - else - { - x_ratio = delta.x()/n; - z_ratio = delta.z()/n; - } - if (x_ratiomax_x_ratio) max_x_ratio = x_ratio; - if (z_ratiomax_z_ratio) max_z_ratio = z_ratio; + // OSG_NOTICE<<" corner v="< rli; rli.set(light_p, virtual_eye, n); rli.traverse(renderStage); @@ -1709,8 +1763,11 @@ bool ViewDependentShadowMap::adjustPerspectiveShadowMapCameraSettings(osgUtil::R OSG_NOTICE<<"min_x_ratio="<