Skip to content

Commit bd05b2a

Browse files
committed
Merge branch 'even-tighter-lispsm-bounds' into 'master'
Reshrink shadow bounds after asymmetric LiSPSM projection See merge request OpenMW/openmw!5272
2 parents a436720 + f516600 commit bd05b2a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

components/sceneutil/mwshadowtechnique.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,6 +3059,31 @@ bool MWShadowTechnique::adjustPerspectiveShadowMapCameraSettings(osgUtil::Render
30593059
0.0, b, 0.0, 0.0 );
30603060
osg::Matrixd light_persp = light_p * lightView * lightPerspective;
30613061

3062+
if (convexHull.valid())
3063+
{
3064+
convexHull.transform(lightView * lightPerspective);
3065+
xMin = osg::maximum(-1.0, convexHull.min(0));
3066+
xMax = osg::minimum(1.0, convexHull.max(0));
3067+
yMin = osg::maximum(-1.0, convexHull.min(1));
3068+
yMax = osg::minimum(1.0, convexHull.max(1));
3069+
3070+
if (xMin != -1.0 || yMin != -1.0 || xMax != 1.0 || yMax != 1.0)
3071+
{
3072+
osg::Matrix m;
3073+
m.makeTranslate(osg::Vec3d(-0.5*(xMax+xMin),
3074+
-0.5*(yMax+yMin),
3075+
0.0));
3076+
3077+
m.postMultScale(osg::Vec3d(2.0/(xMax-xMin),
3078+
2.0/(yMax-yMin),
3079+
1.0));
3080+
3081+
convexHull.transform(m);
3082+
convexHullUnextended.transform(m);
3083+
light_persp.postMult(m);
3084+
}
3085+
}
3086+
30623087
#if 0
30633088
OSG_NOTICE<<"light_p = "<<light_p<<std::endl;
30643089
OSG_NOTICE<<"lightView = "<<lightView<<std::endl;

0 commit comments

Comments
 (0)