From 5d05aadb377215b83b411b6eb893097045a8d241 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 17 May 2018 16:57:01 +0100 Subject: [PATCH] Begin to let settings toggle between CSM and PSSM --- components/sceneutil/mwshadowtechnique.cpp | 32 +++++++++++++--------- components/sceneutil/shadow.cpp | 5 ++++ files/settings-default.cfg | 2 ++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/components/sceneutil/mwshadowtechnique.cpp b/components/sceneutil/mwshadowtechnique.cpp index d2c4c3a8f4..2cf10f4d78 100644 --- a/components/sceneutil/mwshadowtechnique.cpp +++ b/components/sceneutil/mwshadowtechnique.cpp @@ -1188,7 +1188,9 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) if (sm_i+10) + // 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+1getMultipleShadowMapHint() == ShadowSettings::PARALLEL_SPLIT && sm_i+1getMultipleShadowMapHint() == ShadowSettings::PARALLEL_SPLIT) + { + // OSG_NOTICE<<"Need to adjust RTT camera projection and view matrix here, r_start="<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 diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 3cc2b138ee..1ffc745e83 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -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.