1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 13:09:40 +00:00

Begin to let settings toggle between CSM and PSSM

This commit is contained in:
AnyOldName3 2018-05-17 16:57:01 +01:00
parent 7255c266ba
commit 5d05aadb37
3 changed files with 26 additions and 13 deletions

View file

@ -1188,7 +1188,9 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
if (sm_i+1<numShadowMapsPerLight) r_end+=0.01;
if (false)//(sm_i>0)
// We can't add these clipping planes with cascaded shadow maps as they wouldn't be parallel to the light direction.
if (settings->getMultipleShadowMapHint() == ShadowSettings::PARALLEL_SPLIT && sm_i>0)
{
// not the first shadowmap so insert a polytope to clip the scene from before r_start
@ -1203,7 +1205,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
}
if (false)//(sm_i+1<numShadowMapsPerLight)
if (settings->getMultipleShadowMapHint() == ShadowSettings::PARALLEL_SPLIT && sm_i+1<numShadowMapsPerLight)
{
// not the last shadowmap so insert a polytope to clip the scene from beyond r_end
@ -1219,7 +1221,8 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
local_polytope.setupMask();
if (settings->getMultipleShadowMapHint() == ShadowSettings::PARALLEL_SPLIT)
{
// OSG_NOTICE<<"Need to adjust RTT camera projection and view matrix here, r_start="<<r_start<<", r_end="<<r_end<<std::endl;
// OSG_NOTICE<<" textureUnit = "<<textureUnit<<std::endl;
@ -1228,11 +1231,12 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
// OSG_NOTICE<<" mid_r = "<<mid_r<<", range_r = "<<range_r<<std::endl;
/*camera->setProjectionMatrix(
camera->setProjectionMatrix(
camera->getProjectionMatrix() *
osg::Matrixd::translate(osg::Vec3d(0.0,-mid_r,0.0)) *
osg::Matrixd::scale(osg::Vec3d(1.0,2.0/range_r,1.0)));
*/
}
}
@ -2182,9 +2186,11 @@ bool MWShadowTechnique::adjustPerspectiveShadowMapCameraSettings(osgUtil::Render
osg::Vec3d nearPoint = frustum.eye + frustum.frustumCenterLine * viewNear;
osg::Vec3d farPoint = frustum.eye + frustum.frustumCenterLine * viewFar;
// TODO: Aren't these just dot products? Also the double negation of farDist is silly.
double nearDist = frustum.frustumCenterLine.x() * nearPoint.x() + frustum.frustumCenterLine.y() * nearPoint.y() + frustum.frustumCenterLine.z() * nearPoint.z();
double farDist = -frustum.frustumCenterLine.x() * farPoint.x() - frustum.frustumCenterLine.y() * farPoint.y() - frustum.frustumCenterLine.z() * farPoint.z();
convexHull.clip(osg::Plane(frustum.frustumCenterLine, -nearDist));
convexHull.clip(osg::Plane(-frustum.frustumCenterLine, -farDist));

View file

@ -42,6 +42,11 @@ namespace SceneUtil
mShadowTechnique->setSplitPointUniformLogarithmicRatio(Settings::Manager::getFloat("split point uniform logarithmic ratio", "Shadows"));
mShadowTechnique->setSplitPointDeltaBias(Settings::Manager::getFloat("split point bias", "Shadows"));
if (Settings::Manager::getBool("allow shadow map overlap", "Shadows"))
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::CASCADED);
else
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::PARALLEL_SPLIT);
if (Settings::Manager::getBool("enable debug hud", "Shadows"))
mShadowTechnique->enableDebugHUD();
else

View file

@ -512,6 +512,8 @@ companion h = 0.63
enable shadows = false
# How many shadow maps to use - more of these means each shadow map texel covers less area, producing better looking shadows, but may decrease performance.
number of shadow maps = 1
# If true, allow shadow maps to overlap. Counter-intuitively, will produce better results when the light is behind the camera. When enabled, OpenMW uses Cascaded Shadow Maps and when disabled, it uses Parallel Split Shadow Maps.
allow shadow map overlap = true
# Indirectly controls where to split the shadow map(s). Values closer to 1.0 bring more detail closer to the camera (potentially excessively so), and values closer to 0.0 spread it more evenly across the whole viewing distance. 0.5 is recommended for most viewing distances by the original Parallel Split Shadow Maps paper, but this does not take into account use of a Light Space Perspective transformation, so other values may be preferable. If some of the terms used here go over your head, you probably don't want to change this, especially not without reading the associated papers first.
split point uniform logarithmic ratio = 0.5
# Indirectly controls where to split the shadow map(s). Positive values move split points away from the camera and negative values move them towards the camera. Intended to be used in conjunction with changes to 'split point uniform logarithmic ratio' to counteract side effects, but may cause additional, more serious side effects. Read the Parallel Split Shadow Maps paper by F Zhang et al before changing.