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

pull/2915/head
Bret Curtis 5 years ago
parent 476a74c2d3
commit ae729a1ac7

@ -1,6 +1,5 @@
#include "graphicspage.hpp"
#include <csignal>
#include <QDesktopWidget>
#include <QMessageBox>
#include <QDir>
@ -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)

@ -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();
};

@ -2,6 +2,7 @@
#include <osgShadow/ShadowedScene>
#include <components/misc/stringops.hpp>
#include <components/settings/settings.hpp>
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));

@ -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
---------------------

@ -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

@ -201,49 +201,92 @@
</sizepolicy>
</property>
<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">
<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 name="text">
<string>Shadow Distance Limit:</string>
<string>Enable Player Shadows</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="shadowDistanceSpinBox">
<property name="enabled">
<bool>false</bool>
<item row="1" column="0">
<widget class="QCheckBox" name="actorShadowsCheckBox">
<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>
</property>
<property name="text">
<string>Enable Actor Shadows</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;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 primarily inanimate objects. May have a significant performance impact.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string> unit(s)</string>
<property name="text">
<string>Enable Object Shadows</string>
</property>
<property name="minimum">
<number>512</number>
</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="maximum">
<number>81920</number>
<property name="text">
<string>Enable Terrain Shadows</string>
</property>
<property name="value">
<number>8192</number>
</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="7" column="0">
<widget class="QLabel" name="fadeStartLabel">
<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;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;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>Fade Start Multiplier:</string>
<string>Shadow Near Far Computation Method:</string>
</property>
</widget>
</item>
<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">
<item>
<property name="text">
@ -267,85 +310,68 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="actorShadowsCheckBox">
<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>
</property>
<property name="text">
<string>Enable Actor Shadows</string>
</property>
</widget>
</item>
<item row="3" column="0" alignment="Qt::AlignLeft">
<widget class="QCheckBox" name="terrainShadowsCheckBox">
<item row="7" column="0">
<widget class="QCheckBox" name="shadowDistanceCheckBox">
<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>
<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 name="text">
<string>Enable Terrain Shadows</string>
<string>Shadow Distance Limit:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="fadeStartSpinBox">
<widget class="QSpinBox" name="shadowDistanceSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="decimals">
<number>2</number>
<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">
<double>0</double>
<number>512</number>
</property>
<property name="maximum">
<double>1</double>
<number>81920</number>
</property>
<property name="value">
<double>0.90</double>
<number>8192</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="playerShadowsCheckBox">
<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;Enable shadows exclusively for the player character. May have a very 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 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>Enable Player Shadows</string>
<string>Fade Start Multiplier:</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>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="fadeStartSpinBox">
<property name="enabled">
<bool>false</bool>
</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 name="decimals">
<number>2</number>
</property>
<property name="text">
<string>Enable Object Shadows</string>
<property name="minimum">
<double>0</double>
</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 name="maximum">
<double>1</double>
</property>
<property name="text">
<string>Enable Indoor Shadows</string>
<property name="value">
<double>0.90</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>

Loading…
Cancel
Save