1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-28 05:39:39 +00:00

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

This commit is contained in:
Bret Curtis 2020-04-29 11:46:52 +02:00
parent 476a74c2d3
commit ae729a1ac7
6 changed files with 131 additions and 94 deletions

View file

@ -1,6 +1,5 @@
#include "graphicspage.hpp" #include "graphicspage.hpp"
#include <csignal>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QMessageBox> #include <QMessageBox>
#include <QDir> #include <QDir>
@ -145,6 +144,10 @@ bool Launcher::GraphicsPage::loadSettings()
if (mEngineSettings.getBool("enable indoor shadows", "Shadows")) if (mEngineSettings.getBool("enable indoor shadows", "Shadows"))
indoorShadowsCheckBox->setCheckState(Qt::Checked); 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"); int shadowDistLimit = mEngineSettings.getInt("maximum shadow map distance", "Shadows");
if (shadowDistLimit > 0) if (shadowDistLimit > 0)
{ {
@ -231,7 +234,7 @@ void Launcher::GraphicsPage::saveSettings()
bool cPlayerShadows = playerShadowsCheckBox->checkState(); bool cPlayerShadows = playerShadowsCheckBox->checkState();
if (cActorShadows || cObjectShadows || cTerrainShadows || cPlayerShadows) if (cActorShadows || cObjectShadows || cTerrainShadows || cPlayerShadows)
{ {
if (mEngineSettings.getBool("enable shadows", "Shadows") != true) if (!mEngineSettings.getBool("enable shadows", "Shadows"))
mEngineSettings.setBool("enable shadows", "Shadows", true); mEngineSettings.setBool("enable shadows", "Shadows", true);
if (mEngineSettings.getBool("actor shadows", "Shadows") != cActorShadows) if (mEngineSettings.getBool("actor shadows", "Shadows") != cActorShadows)
mEngineSettings.setBool("actor shadows", "Shadows", cActorShadows); mEngineSettings.setBool("actor shadows", "Shadows", cActorShadows);
@ -263,6 +266,10 @@ void Launcher::GraphicsPage::saveSettings()
int cShadowRes = shadowResolutionComboBox->currentText().toInt(); int cShadowRes = shadowResolutionComboBox->currentText().toInt();
if (cShadowRes != mEngineSettings.getInt("shadow map resolution", "Shadows")) if (cShadowRes != mEngineSettings.getInt("shadow map resolution", "Shadows"))
mEngineSettings.setInt("shadow map resolution", "Shadows", cShadowRes); 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) QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)

View file

@ -38,8 +38,8 @@ namespace Launcher
Files::ConfigurationManager &mCfgMgr; Files::ConfigurationManager &mCfgMgr;
Settings::Manager &mEngineSettings; Settings::Manager &mEngineSettings;
QStringList getAvailableResolutions(int screen); static QStringList getAvailableResolutions(int screen);
QRect getMaximumResolution(); static QRect getMaximumResolution();
bool setupSDL(); bool setupSDL();
}; };

View file

@ -2,6 +2,7 @@
#include <osgShadow/ShadowedScene> #include <osgShadow/ShadowedScene>
#include <components/misc/stringops.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
namespace SceneUtil namespace SceneUtil
@ -38,11 +39,14 @@ namespace SceneUtil
} }
mShadowSettings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows")); 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); 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); mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows");
mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres)); mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres));

View file

@ -80,15 +80,15 @@ enable debug overlay
Enable or disable the debug overlay to see the area covered by each shadow map. 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. 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 :Type: string
:Range: True/False :Range: bounding volumes|primitives
:Default: True :Default: bounding volumes
With this setting enabled, attempt to better use the shadow map(s) by making them cover a smaller area. Two different ways to make better use of shadow map(s) by making them cover a smaller area.
May have a minor to major performance impact. While primitives give better results at expense of more CPU, bounding volumes gives better performance overall but with lower quality shadows.
shadow map resolution shadow map resolution
--------------------- ---------------------

View file

@ -805,8 +805,8 @@ enable debug hud = false
# Enable the debug overlay to see where each shadow map affects. # Enable the debug overlay to see where each shadow map affects.
enable debug overlay = false 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. # 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.
compute tight scene bounds = true 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. # 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 shadow map resolution = 1024

View file

@ -201,49 +201,92 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QGridLayout" name="shadowsLayout" columnstretch="0,0"> <layout class="QGridLayout" name="shadowsLayout" columnstretch="0,0">
<item row="6" column="0">
<widget class="QCheckBox" name="shadowDistanceCheckBox"> <item row="0" column="0">
<widget class="QCheckBox" name="playerShadowsCheckBox">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The distance from the camera at which shadows completely disappear.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows exclusively for the player character. May have a very minor performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Shadow Distance Limit:</string> <string>Enable Player Shadows</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="1" column="0">
<widget class="QSpinBox" name="shadowDistanceSpinBox"> <widget class="QCheckBox" name="actorShadowsCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;64 game units is 1 real life yard or about 0.9 m&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows for NPCs and creatures besides the player character. May have a minor performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="suffix"> <property name="text">
<string> unit(s)</string> <string>Enable Actor Shadows</string>
</property>
<property name="minimum">
<number>512</number>
</property>
<property name="maximum">
<number>81920</number>
</property>
<property name="value">
<number>8192</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="2" column="0">
<widget class="QLabel" name="fadeStartLabel"> <widget class="QCheckBox" name="objectShadowsCheckBox">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The fraction of the limit above at which shadows begin to gradually fade away.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows for primarily inanimate objects. May have a significant performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Fade Start Multiplier:</string> <string>Enable Object Shadows</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="terrainShadowsCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows for the terrain including distant terrain. May have a significant performance and shadow quality impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Terrain Shadows</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="indoorShadowsCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Due to limitations with Morrowind's data, only actors can cast shadows indoors, which some might feel is distracting.&lt;/p&gt;&lt;p&gt;Has no effect if actor/player shadows are not enabled.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Indoor Shadows</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="shadowNearFarComputationLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Type of "near far plane" computation method to be used. Bounding Volumes (default) for better performance, Primitives for better looking shadows or none.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Shadow Near Far Computation Method:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="5" column="1">
<widget class="QComboBox" name="shadowNearFarComputationComboBox">
<item>
<property name="text">
<string>bounding volumes</string>
</property>
</item>
<item>
<property name="text">
<string>primitives</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="shadowResolutionLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The resolution of each individual shadow map. Increasing it significantly improves shadow quality but may have a minor performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Shadow Map Resolution:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="shadowResolutionComboBox"> <widget class="QComboBox" name="shadowResolutionComboBox">
<item> <item>
<property name="text"> <property name="text">
@ -267,27 +310,49 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="7" column="0">
<widget class="QCheckBox" name="actorShadowsCheckBox"> <widget class="QCheckBox" name="shadowDistanceCheckBox">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows for NPCs and creatures besides the player character. May have a minor performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The distance from the camera at which shadows completely disappear.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Enable Actor Shadows</string> <string>Shadow Distance Limit:</string>
</property>
</widget>
</item>
<item row="3" column="0" alignment="Qt::AlignLeft">
<widget class="QCheckBox" name="terrainShadowsCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows for the terrain including distant terrain. May have a significant performance and shadow quality impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Terrain Shadows</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="7" column="1">
<widget class="QSpinBox" name="shadowDistanceSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;64 game units is 1 real life yard or about 0.9 m&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string> unit(s)</string>
</property>
<property name="minimum">
<number>512</number>
</property>
<property name="maximum">
<number>81920</number>
</property>
<property name="value">
<number>8192</number>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="fadeStartLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The fraction of the limit above at which shadows begin to gradually fade away.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Fade Start Multiplier:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="fadeStartSpinBox"> <widget class="QDoubleSpinBox" name="fadeStartSpinBox">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -306,46 +371,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QCheckBox" name="playerShadowsCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows exclusively for the player character. May have a very minor performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Player Shadows</string>
</property>
</widget>
</item>
<item row="5" column="0" alignment="Qt::AlignLeft">
<widget class="QLabel" name="shadowResolutionLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The resolution of each individual shadow map. Increasing it significantly improves shadow quality but may have a minor performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Shadow Map Resolution:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="objectShadowsCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable shadows for primarily inanimate objects. May have a significant performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Object Shadows</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="indoorShadowsCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Due to limitations with Morrowind's data, only actors can cast shadows indoors, which some might feel is distracting.&lt;/p&gt;&lt;p&gt;Has no effect if actor/player shadows are not enabled.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Indoor Shadows</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>