From ae729a1ac74ff2e1891bfd770f13e746f2de1eca Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 29 Apr 2020 11:46:52 +0200 Subject: [PATCH 1/6] add ability to set the type of near far method to be used in shadow calculation; default to bounding volumes; cleaned up code while there and re-ordered items --- apps/launcher/graphicspage.cpp | 11 +- apps/launcher/graphicspage.hpp | 4 +- components/sceneutil/shadow.cpp | 8 +- .../reference/modding/settings/shadows.rst | 14 +- files/settings-default.cfg | 4 +- files/ui/graphicspage.ui | 184 ++++++++++-------- 6 files changed, 131 insertions(+), 94 deletions(-) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 6bc22bad69..421691a55e 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -1,6 +1,5 @@ #include "graphicspage.hpp" -#include #include #include #include @@ -145,6 +144,10 @@ bool Launcher::GraphicsPage::loadSettings() if (mEngineSettings.getBool("enable indoor shadows", "Shadows")) indoorShadowsCheckBox->setCheckState(Qt::Checked); + shadowNearFarComputationComboBox->setCurrentIndex( + shadowNearFarComputationComboBox->findText( + QString(tr(mEngineSettings.getString("near far computation", "Shadows").c_str())))); + int shadowDistLimit = mEngineSettings.getInt("maximum shadow map distance", "Shadows"); if (shadowDistLimit > 0) { @@ -231,7 +234,7 @@ void Launcher::GraphicsPage::saveSettings() bool cPlayerShadows = playerShadowsCheckBox->checkState(); if (cActorShadows || cObjectShadows || cTerrainShadows || cPlayerShadows) { - if (mEngineSettings.getBool("enable shadows", "Shadows") != true) + if (!mEngineSettings.getBool("enable shadows", "Shadows")) mEngineSettings.setBool("enable shadows", "Shadows", true); if (mEngineSettings.getBool("actor shadows", "Shadows") != cActorShadows) mEngineSettings.setBool("actor shadows", "Shadows", cActorShadows); @@ -263,6 +266,10 @@ void Launcher::GraphicsPage::saveSettings() int cShadowRes = shadowResolutionComboBox->currentText().toInt(); if (cShadowRes != mEngineSettings.getInt("shadow map resolution", "Shadows")) mEngineSettings.setInt("shadow map resolution", "Shadows", cShadowRes); + + auto cShadowNearFarMode = shadowNearFarComputationComboBox->currentText().toStdString(); + if (cShadowNearFarMode != mEngineSettings.getString("near far computation", "Shadows")) + mEngineSettings.setString("near far computation", "Shadows", cShadowNearFarMode); } QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen) diff --git a/apps/launcher/graphicspage.hpp b/apps/launcher/graphicspage.hpp index b230625fc6..4ce5b584f0 100644 --- a/apps/launcher/graphicspage.hpp +++ b/apps/launcher/graphicspage.hpp @@ -38,8 +38,8 @@ namespace Launcher Files::ConfigurationManager &mCfgMgr; Settings::Manager &mEngineSettings; - QStringList getAvailableResolutions(int screen); - QRect getMaximumResolution(); + static QStringList getAvailableResolutions(int screen); + static QRect getMaximumResolution(); bool setupSDL(); }; diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index a1cd1d660b..7c2dfd7671 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -2,6 +2,7 @@ #include +#include #include namespace SceneUtil @@ -38,11 +39,14 @@ namespace SceneUtil } mShadowSettings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows")); - if (Settings::Manager::getBool("compute tight scene bounds", "Shadows")) + + std::string computeNearFarMode = Settings::Manager::getString("near far computation", "Shadows"); + if (Misc::StringUtils::lowerCase(computeNearFarMode) == "primitives") mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES); - else + else if (Misc::StringUtils::lowerCase(computeNearFarMode) == "bounding volumes") mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); + int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres)); diff --git a/docs/source/reference/modding/settings/shadows.rst b/docs/source/reference/modding/settings/shadows.rst index d0d92a6e26..861cc03efd 100644 --- a/docs/source/reference/modding/settings/shadows.rst +++ b/docs/source/reference/modding/settings/shadows.rst @@ -80,15 +80,15 @@ enable debug overlay Enable or disable the debug overlay to see the area covered by each shadow map. This setting is only recommended for developers, bug reporting and advanced users performing fine-tuning of shadow settings. -compute tight scene bounds --------------------------- +near far computation +-------------------- -:Type: boolean -:Range: True/False -:Default: True +:Type: string +:Range: bounding volumes|primitives +:Default: bounding volumes -With this setting enabled, attempt to better use the shadow map(s) by making them cover a smaller area. -May have a minor to major performance impact. +Two different ways to make better use of shadow map(s) by making them cover a smaller area. +While primitives give better results at expense of more CPU, bounding volumes gives better performance overall but with lower quality shadows. shadow map resolution --------------------- diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 6703e77326..7fc2db728c 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -805,8 +805,8 @@ enable debug hud = false # Enable the debug overlay to see where each shadow map affects. enable debug overlay = false -# Attempt to better use the shadow map by making them cover a smaller area. May have a minor to major performance impact. -compute tight scene bounds = true +# Used to set type of tight scene bound calculation that makes use the shadow map by making them cover a smaller area. "bounding volumes" (default) is less precise shadows but lower CPU cost or "primitives" for more precise shadows at expense of CPU. +near far computation = bounding volumes # How large to make the shadow map(s). Higher values increase GPU load, but can produce better-looking results. Power-of-two values may turn out to be faster on some GPU/driver combinations. shadow map resolution = 1024 diff --git a/files/ui/graphicspage.ui b/files/ui/graphicspage.ui index 18d220797e..1b11632e53 100644 --- a/files/ui/graphicspage.ui +++ b/files/ui/graphicspage.ui @@ -201,49 +201,92 @@ - - + + + - <html><head/><body><p>The distance from the camera at which shadows completely disappear.</p></body></html> + <html><head/><body><p>Enable shadows exclusively for the player character. May have a very minor performance impact.</p></body></html> - Shadow Distance Limit: + Enable Player Shadows - - - - false - + + - <html><head/><body><p>64 game units is 1 real life yard or about 0.9 m</p></body></html> + <html><head/><body><p>Enable shadows for NPCs and creatures besides the player character. May have a minor performance impact.</p></body></html> - - unit(s) - - - 512 - - - 81920 - - - 8192 + + Enable Actor Shadows - - + + - <html><head/><body><p>The fraction of the limit above at which shadows begin to gradually fade away.</p></body></html> + <html><head/><body><p>Enable shadows for primarily inanimate objects. May have a significant performance impact.</p></body></html> - Fade Start Multiplier: + Enable Object Shadows + + + + + + + <html><head/><body><p>Enable shadows for the terrain including distant terrain. May have a significant performance and shadow quality impact.</p></body></html> + + + Enable Terrain Shadows + + + + + + + <html><head/><body><p>Due to limitations with Morrowind's data, only actors can cast shadows indoors, which some might feel is distracting.</p><p>Has no effect if actor/player shadows are not enabled.</p></body></html> + + + Enable Indoor Shadows + + + + + + + <html><head/><body><p>Type of "near far plane" computation method to be used. Bounding Volumes (default) for better performance, Primitives for better looking shadows or none.</p></body></html> + + + Shadow Near Far Computation Method: + + + + bounding volumes + + + + + primitives + + + + + + + + <html><head/><body><p>The resolution of each individual shadow map. Increasing it significantly improves shadow quality but may have a minor performance impact.</p></body></html> + + + Shadow Map Resolution: + + + + @@ -267,27 +310,49 @@ - - + + - <html><head/><body><p>Enable shadows for NPCs and creatures besides the player character. May have a minor performance impact.</p></body></html> + <html><head/><body><p>The distance from the camera at which shadows completely disappear.</p></body></html> - Enable Actor Shadows - - - - - - - <html><head/><body><p>Enable shadows for the terrain including distant terrain. May have a significant performance and shadow quality impact.</p></body></html> - - - Enable Terrain Shadows + Shadow Distance Limit: + + + false + + + <html><head/><body><p>64 game units is 1 real life yard or about 0.9 m</p></body></html> + + + unit(s) + + + 512 + + + 81920 + + + 8192 + + + + + + + <html><head/><body><p>The fraction of the limit above at which shadows begin to gradually fade away.</p></body></html> + + + Fade Start Multiplier: + + + + false @@ -306,46 +371,7 @@ - - - - <html><head/><body><p>Enable shadows exclusively for the player character. May have a very minor performance impact.</p></body></html> - - - Enable Player Shadows - - - - - - - <html><head/><body><p>The resolution of each individual shadow map. Increasing it significantly improves shadow quality but may have a minor performance impact.</p></body></html> - - - Shadow Map Resolution: - - - - - - - <html><head/><body><p>Enable shadows for primarily inanimate objects. May have a significant performance impact.</p></body></html> - - - Enable Object Shadows - - - - - - - <html><head/><body><p>Due to limitations with Morrowind's data, only actors can cast shadows indoors, which some might feel is distracting.</p><p>Has no effect if actor/player shadows are not enabled.</p></body></html> - - - Enable Indoor Shadows - - - + From d38c3e971c71fe6de9227cc00b2d6c9371ee617d Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 29 Apr 2020 17:05:08 +0200 Subject: [PATCH 2/6] remove extra line --- components/sceneutil/shadow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index 7c2dfd7671..f6858fca00 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -46,7 +46,6 @@ namespace SceneUtil else if (Misc::StringUtils::lowerCase(computeNearFarMode) == "bounding volumes") mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); - int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres)); From 980525cba47ffc7aabcd339e308d808bed844c9c Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 29 Apr 2020 17:08:12 +0200 Subject: [PATCH 3/6] better said --- files/settings-default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 7fc2db728c..44252b3bd7 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -805,7 +805,7 @@ enable debug hud = false # Enable the debug overlay to see where each shadow map affects. enable debug overlay = false -# Used to set type of tight scene bound calculation that makes use the shadow map by making them cover a smaller area. "bounding volumes" (default) is less precise shadows but lower CPU cost or "primitives" for more precise shadows at expense of CPU. +# Used to set the type of tight scene bound calculation method to be used by the shadow map that covers a smaller area. "bounding volumes" (default) is less precise shadows but better performance or "primitives" for more precise shadows at expense of CPU. near far computation = bounding volumes # How large to make the shadow map(s). Higher values increase GPU load, but can produce better-looking results. Power-of-two values may turn out to be faster on some GPU/driver combinations. From bb5fe13e1395775dfe66f587a3bba01371b6feef Mon Sep 17 00:00:00 2001 From: psi29a Date: Wed, 29 Apr 2020 23:06:44 +0000 Subject: [PATCH 4/6] Make sure it is either one or the other with the default to bounding volumes. --- components/sceneutil/shadow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index f6858fca00..0476768f8c 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -43,7 +43,7 @@ namespace SceneUtil std::string computeNearFarMode = Settings::Manager::getString("near far computation", "Shadows"); if (Misc::StringUtils::lowerCase(computeNearFarMode) == "primitives") mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES); - else if (Misc::StringUtils::lowerCase(computeNearFarMode) == "bounding volumes") + else mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); From aca223f6c80f33e22e3fb1e85785616408030f87 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 30 Apr 2020 17:41:26 +0200 Subject: [PATCH 5/6] fix unrelated rst issue; rename to bounds --- docs/source/reference/modding/settings/shadows.rst | 6 +++--- files/settings-default.cfg | 4 ++-- files/ui/graphicspage.ui | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/reference/modding/settings/shadows.rst b/docs/source/reference/modding/settings/shadows.rst index 861cc03efd..746e9b0df1 100644 --- a/docs/source/reference/modding/settings/shadows.rst +++ b/docs/source/reference/modding/settings/shadows.rst @@ -71,7 +71,7 @@ Enable or disable the debug hud to see what the shadow map(s) contain. This setting is only recommended for developers, bug reporting and advanced users performing fine-tuning of shadow settings. enable debug overlay ----------------- +-------------------- :Type: boolean :Range: True/False @@ -84,11 +84,11 @@ near far computation -------------------- :Type: string -:Range: bounding volumes|primitives +:Range: primitives|bounds :Default: bounding volumes Two different ways to make better use of shadow map(s) by making them cover a smaller area. -While primitives give better results at expense of more CPU, bounding volumes gives better performance overall but with lower quality shadows. +While primitives give better shadows at expense of more CPU, bounds gives better performance overall but with lower quality shadows. shadow map resolution --------------------- diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 44252b3bd7..5a0d787f92 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -805,8 +805,8 @@ enable debug hud = false # Enable the debug overlay to see where each shadow map affects. enable debug overlay = false -# Used to set the type of tight scene bound calculation method to be used by the shadow map that covers a smaller area. "bounding volumes" (default) is less precise shadows but better performance or "primitives" for more precise shadows at expense of CPU. -near far computation = bounding volumes +# Used to set the type of tight scene bound calculation method to be used by the shadow map that covers a smaller area. "bounds" (default) is less precise shadows but better performance or "primitives" for more precise shadows at expense of CPU. +near far computation = bounds # How large to make the shadow map(s). Higher values increase GPU load, but can produce better-looking results. Power-of-two values may turn out to be faster on some GPU/driver combinations. shadow map resolution = 1024 diff --git a/files/ui/graphicspage.ui b/files/ui/graphicspage.ui index 1b11632e53..9a7d986a74 100644 --- a/files/ui/graphicspage.ui +++ b/files/ui/graphicspage.ui @@ -266,7 +266,7 @@ - bounding volumes + bounds From 5f0f2f0f169e373b43825eb7d138f3ec6892c4d5 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Fri, 1 May 2020 00:34:31 +0200 Subject: [PATCH 6/6] rename to better reflect what is going on per AnyOldName3 comment; added none option --- apps/launcher/graphicspage.cpp | 12 ++++++------ components/sceneutil/shadow.cpp | 6 +++--- docs/source/reference/modding/settings/shadows.rst | 6 +++--- files/settings-default.cfg | 2 +- files/ui/graphicspage.ui | 13 +++++++++---- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 421691a55e..d48e627e19 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -144,9 +144,9 @@ bool Launcher::GraphicsPage::loadSettings() if (mEngineSettings.getBool("enable indoor shadows", "Shadows")) indoorShadowsCheckBox->setCheckState(Qt::Checked); - shadowNearFarComputationComboBox->setCurrentIndex( - shadowNearFarComputationComboBox->findText( - QString(tr(mEngineSettings.getString("near far computation", "Shadows").c_str())))); + shadowComputeSceneBoundsComboBox->setCurrentIndex( + shadowComputeSceneBoundsComboBox->findText( + QString(tr(mEngineSettings.getString("compute scene bounds", "Shadows").c_str())))); int shadowDistLimit = mEngineSettings.getInt("maximum shadow map distance", "Shadows"); if (shadowDistLimit > 0) @@ -267,9 +267,9 @@ void Launcher::GraphicsPage::saveSettings() if (cShadowRes != mEngineSettings.getInt("shadow map resolution", "Shadows")) mEngineSettings.setInt("shadow map resolution", "Shadows", cShadowRes); - auto cShadowNearFarMode = shadowNearFarComputationComboBox->currentText().toStdString(); - if (cShadowNearFarMode != mEngineSettings.getString("near far computation", "Shadows")) - mEngineSettings.setString("near far computation", "Shadows", cShadowNearFarMode); + auto cComputeSceneBounds = shadowComputeSceneBoundsComboBox->currentText().toStdString(); + if (cComputeSceneBounds != mEngineSettings.getString("compute scene bounds", "Shadows")) + mEngineSettings.setString("compute scene bounds", "Shadows", cComputeSceneBounds); } QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen) diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index 0476768f8c..1e14fbbb13 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -40,10 +40,10 @@ namespace SceneUtil mShadowSettings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows")); - std::string computeNearFarMode = Settings::Manager::getString("near far computation", "Shadows"); - if (Misc::StringUtils::lowerCase(computeNearFarMode) == "primitives") + std::string computeSceneBounds = Settings::Manager::getString("compute scene bounds", "Shadows"); + if (Misc::StringUtils::lowerCase(computeSceneBounds) == "primitives") mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES); - else + else if (Misc::StringUtils::lowerCase(computeSceneBounds) == "bounds") mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); diff --git a/docs/source/reference/modding/settings/shadows.rst b/docs/source/reference/modding/settings/shadows.rst index 746e9b0df1..0670a81092 100644 --- a/docs/source/reference/modding/settings/shadows.rst +++ b/docs/source/reference/modding/settings/shadows.rst @@ -80,15 +80,15 @@ enable debug overlay Enable or disable the debug overlay to see the area covered by each shadow map. This setting is only recommended for developers, bug reporting and advanced users performing fine-tuning of shadow settings. -near far computation +compute scene bounds -------------------- :Type: string -:Range: primitives|bounds +:Range: primitives|bounds|none :Default: bounding volumes Two different ways to make better use of shadow map(s) by making them cover a smaller area. -While primitives give better shadows at expense of more CPU, bounds gives better performance overall but with lower quality shadows. +While primitives give better shadows at expense of more CPU, bounds gives better performance overall but with lower quality shadows. There is also the ability to disable this computation with none. shadow map resolution --------------------- diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 5a0d787f92..91c0443ec9 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -806,7 +806,7 @@ enable debug hud = false enable debug overlay = false # Used to set the type of tight scene bound calculation method to be used by the shadow map that covers a smaller area. "bounds" (default) is less precise shadows but better performance or "primitives" for more precise shadows at expense of CPU. -near far computation = bounds +compute scene bounds = bounds # How large to make the shadow map(s). Higher values increase GPU load, but can produce better-looking results. Power-of-two values may turn out to be faster on some GPU/driver combinations. shadow map resolution = 1024 diff --git a/files/ui/graphicspage.ui b/files/ui/graphicspage.ui index 9a7d986a74..cfa2c800c1 100644 --- a/files/ui/graphicspage.ui +++ b/files/ui/graphicspage.ui @@ -253,17 +253,17 @@ - + - <html><head/><body><p>Type of "near far plane" computation method to be used. Bounding Volumes (default) for better performance, Primitives for better looking shadows or none.</p></body></html> + <html><head/><body><p>Type of "compute scene bounds" computation method to be used. Bounds (default) for good balance between performance and shadow quality, primitives for better looking shadows or none for no computation.</p></body></html> Shadow Near Far Computation Method: - - + compute scene bounds + bounds @@ -274,6 +274,11 @@ primitives + + + none + +