mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 21:35:24 +00:00
Merge branch 'settings_values_shadows' into 'master'
Use settings values for Shadows settings (#6876) See merge request OpenMW/openmw!3550
This commit is contained in:
commit
07594037ca
@ -158,32 +158,32 @@ bool Launcher::GraphicsPage::loadSettings()
|
||||
lightingMethodComboBox->setCurrentIndex(lightingMethod);
|
||||
|
||||
// Shadows
|
||||
if (Settings::Manager::getBool("actor shadows", "Shadows"))
|
||||
if (Settings::shadows().mActorShadows)
|
||||
actorShadowsCheckBox->setCheckState(Qt::Checked);
|
||||
if (Settings::Manager::getBool("player shadows", "Shadows"))
|
||||
if (Settings::shadows().mPlayerShadows)
|
||||
playerShadowsCheckBox->setCheckState(Qt::Checked);
|
||||
if (Settings::Manager::getBool("terrain shadows", "Shadows"))
|
||||
if (Settings::shadows().mTerrainShadows)
|
||||
terrainShadowsCheckBox->setCheckState(Qt::Checked);
|
||||
if (Settings::Manager::getBool("object shadows", "Shadows"))
|
||||
if (Settings::shadows().mObjectShadows)
|
||||
objectShadowsCheckBox->setCheckState(Qt::Checked);
|
||||
if (Settings::Manager::getBool("enable indoor shadows", "Shadows"))
|
||||
if (Settings::shadows().mEnableIndoorShadows)
|
||||
indoorShadowsCheckBox->setCheckState(Qt::Checked);
|
||||
|
||||
shadowComputeSceneBoundsComboBox->setCurrentIndex(shadowComputeSceneBoundsComboBox->findText(
|
||||
QString(tr(Settings::Manager::getString("compute scene bounds", "Shadows").c_str()))));
|
||||
shadowComputeSceneBoundsComboBox->setCurrentIndex(
|
||||
shadowComputeSceneBoundsComboBox->findText(QString(tr(Settings::shadows().mComputeSceneBounds.get().c_str()))));
|
||||
|
||||
int shadowDistLimit = Settings::Manager::getInt("maximum shadow map distance", "Shadows");
|
||||
const int shadowDistLimit = Settings::shadows().mMaximumShadowMapDistance;
|
||||
if (shadowDistLimit > 0)
|
||||
{
|
||||
shadowDistanceCheckBox->setCheckState(Qt::Checked);
|
||||
shadowDistanceSpinBox->setValue(shadowDistLimit);
|
||||
}
|
||||
|
||||
float shadowFadeStart = Settings::Manager::getFloat("shadow fade start", "Shadows");
|
||||
const float shadowFadeStart = Settings::shadows().mShadowFadeStart;
|
||||
if (shadowFadeStart != 0)
|
||||
fadeStartSpinBox->setValue(shadowFadeStart);
|
||||
|
||||
int shadowRes = Settings::Manager::getInt("shadow map resolution", "Shadows");
|
||||
const int shadowRes = Settings::shadows().mShadowMapResolution;
|
||||
int shadowResIndex = shadowResolutionComboBox->findText(QString::number(shadowRes));
|
||||
if (shadowResIndex != -1)
|
||||
shadowResolutionComboBox->setCurrentIndex(shadowResIndex);
|
||||
@ -240,55 +240,36 @@ void Launcher::GraphicsPage::saveSettings()
|
||||
Settings::shaders().mLightingMethod.set(lightingMethodMap[lightingMethodComboBox->currentIndex()]);
|
||||
|
||||
// Shadows
|
||||
int cShadowDist = shadowDistanceCheckBox->checkState() != Qt::Unchecked ? shadowDistanceSpinBox->value() : 0;
|
||||
if (Settings::Manager::getInt("maximum shadow map distance", "Shadows") != cShadowDist)
|
||||
Settings::Manager::setInt("maximum shadow map distance", "Shadows", cShadowDist);
|
||||
float cFadeStart = fadeStartSpinBox->value();
|
||||
if (cShadowDist > 0 && Settings::Manager::getFloat("shadow fade start", "Shadows") != cFadeStart)
|
||||
Settings::Manager::setFloat("shadow fade start", "Shadows", cFadeStart);
|
||||
const int cShadowDist = shadowDistanceCheckBox->checkState() != Qt::Unchecked ? shadowDistanceSpinBox->value() : 0;
|
||||
Settings::shadows().mMaximumShadowMapDistance.set(cShadowDist);
|
||||
const float cFadeStart = fadeStartSpinBox->value();
|
||||
if (cShadowDist > 0)
|
||||
Settings::shadows().mShadowFadeStart.set(cFadeStart);
|
||||
|
||||
bool cActorShadows = actorShadowsCheckBox->checkState();
|
||||
bool cObjectShadows = objectShadowsCheckBox->checkState();
|
||||
bool cTerrainShadows = terrainShadowsCheckBox->checkState();
|
||||
bool cPlayerShadows = playerShadowsCheckBox->checkState();
|
||||
const bool cActorShadows = actorShadowsCheckBox->checkState() != Qt::Unchecked;
|
||||
const bool cObjectShadows = objectShadowsCheckBox->checkState() != Qt::Unchecked;
|
||||
const bool cTerrainShadows = terrainShadowsCheckBox->checkState() != Qt::Unchecked;
|
||||
const bool cPlayerShadows = playerShadowsCheckBox->checkState() != Qt::Unchecked;
|
||||
if (cActorShadows || cObjectShadows || cTerrainShadows || cPlayerShadows)
|
||||
{
|
||||
if (!Settings::Manager::getBool("enable shadows", "Shadows"))
|
||||
Settings::Manager::setBool("enable shadows", "Shadows", true);
|
||||
if (Settings::Manager::getBool("actor shadows", "Shadows") != cActorShadows)
|
||||
Settings::Manager::setBool("actor shadows", "Shadows", cActorShadows);
|
||||
if (Settings::Manager::getBool("player shadows", "Shadows") != cPlayerShadows)
|
||||
Settings::Manager::setBool("player shadows", "Shadows", cPlayerShadows);
|
||||
if (Settings::Manager::getBool("object shadows", "Shadows") != cObjectShadows)
|
||||
Settings::Manager::setBool("object shadows", "Shadows", cObjectShadows);
|
||||
if (Settings::Manager::getBool("terrain shadows", "Shadows") != cTerrainShadows)
|
||||
Settings::Manager::setBool("terrain shadows", "Shadows", cTerrainShadows);
|
||||
Settings::shadows().mEnableShadows.set(true);
|
||||
Settings::shadows().mActorShadows.set(cActorShadows);
|
||||
Settings::shadows().mPlayerShadows.set(cPlayerShadows);
|
||||
Settings::shadows().mObjectShadows.set(cObjectShadows);
|
||||
Settings::shadows().mTerrainShadows.set(cTerrainShadows);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Settings::Manager::getBool("enable shadows", "Shadows"))
|
||||
Settings::Manager::setBool("enable shadows", "Shadows", false);
|
||||
if (Settings::Manager::getBool("actor shadows", "Shadows"))
|
||||
Settings::Manager::setBool("actor shadows", "Shadows", false);
|
||||
if (Settings::Manager::getBool("player shadows", "Shadows"))
|
||||
Settings::Manager::setBool("player shadows", "Shadows", false);
|
||||
if (Settings::Manager::getBool("object shadows", "Shadows"))
|
||||
Settings::Manager::setBool("object shadows", "Shadows", false);
|
||||
if (Settings::Manager::getBool("terrain shadows", "Shadows"))
|
||||
Settings::Manager::setBool("terrain shadows", "Shadows", false);
|
||||
Settings::shadows().mEnableShadows.set(false);
|
||||
Settings::shadows().mActorShadows.set(false);
|
||||
Settings::shadows().mPlayerShadows.set(false);
|
||||
Settings::shadows().mObjectShadows.set(false);
|
||||
Settings::shadows().mTerrainShadows.set(false);
|
||||
}
|
||||
|
||||
bool cIndoorShadows = indoorShadowsCheckBox->checkState();
|
||||
if (Settings::Manager::getBool("enable indoor shadows", "Shadows") != cIndoorShadows)
|
||||
Settings::Manager::setBool("enable indoor shadows", "Shadows", cIndoorShadows);
|
||||
|
||||
int cShadowRes = shadowResolutionComboBox->currentText().toInt();
|
||||
if (cShadowRes != Settings::Manager::getInt("shadow map resolution", "Shadows"))
|
||||
Settings::Manager::setInt("shadow map resolution", "Shadows", cShadowRes);
|
||||
|
||||
auto cComputeSceneBounds = shadowComputeSceneBoundsComboBox->currentText().toStdString();
|
||||
if (cComputeSceneBounds != Settings::Manager::getString("compute scene bounds", "Shadows"))
|
||||
Settings::Manager::setString("compute scene bounds", "Shadows", cComputeSceneBounds);
|
||||
Settings::shadows().mEnableIndoorShadows.set(indoorShadowsCheckBox->checkState() != Qt::Unchecked);
|
||||
Settings::shadows().mShadowMapResolution.set(shadowResolutionComboBox->currentText().toInt());
|
||||
Settings::shadows().mComputeSceneBounds.set(shadowComputeSceneBoundsComboBox->currentText().toStdString());
|
||||
}
|
||||
|
||||
QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
|
||||
|
@ -247,7 +247,7 @@ namespace MWRender
|
||||
defaultMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(0.f, 0.f, 0.f, 0.f));
|
||||
stateset->setAttribute(defaultMat);
|
||||
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(stateset);
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(Settings::shadows(), *stateset);
|
||||
|
||||
// assign large value to effectively turn off fog
|
||||
// shaders don't respect glDisable(GL_FOG)
|
||||
|
@ -763,7 +763,7 @@ namespace MWRender
|
||||
|
||||
lightSource->setStateSetModes(*stateset, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
|
||||
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(stateset);
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(Settings::shadows(), *stateset);
|
||||
|
||||
// override sun for local map
|
||||
SceneUtil::configureStateSetSunOverride(static_cast<SceneUtil::LightManager*>(mSceneRoot), light, stateset);
|
||||
|
@ -331,8 +331,8 @@ namespace MWRender
|
||||
// Shadows and radial fog have problems with fixed-function mode.
|
||||
bool forceShaders = Settings::fog().mRadialFog || Settings::fog().mExponentialFog
|
||||
|| Settings::shaders().mSoftParticles || Settings::shaders().mForceShaders
|
||||
|| Settings::Manager::getBool("enable shadows", "Shadows")
|
||||
|| lightingMethod != SceneUtil::LightingMethod::FFP || reverseZ || mSkyBlending || Stereo::getMultiview();
|
||||
|| Settings::shadows().mEnableShadows || lightingMethod != SceneUtil::LightingMethod::FFP || reverseZ
|
||||
|| mSkyBlending || Stereo::getMultiview();
|
||||
resourceSystem->getSceneManager()->setForceShaders(forceShaders);
|
||||
|
||||
// FIXME: calling dummy method because terrain needs to know whether lighting is clamped
|
||||
@ -367,22 +367,22 @@ namespace MWRender
|
||||
sceneRoot->setName("Scene Root");
|
||||
|
||||
int shadowCastingTraversalMask = Mask_Scene;
|
||||
if (Settings::Manager::getBool("actor shadows", "Shadows"))
|
||||
if (Settings::shadows().mActorShadows)
|
||||
shadowCastingTraversalMask |= Mask_Actor;
|
||||
if (Settings::Manager::getBool("player shadows", "Shadows"))
|
||||
if (Settings::shadows().mPlayerShadows)
|
||||
shadowCastingTraversalMask |= Mask_Player;
|
||||
|
||||
int indoorShadowCastingTraversalMask = shadowCastingTraversalMask;
|
||||
if (Settings::Manager::getBool("object shadows", "Shadows"))
|
||||
if (Settings::shadows().mObjectShadows)
|
||||
shadowCastingTraversalMask |= (Mask_Object | Mask_Static);
|
||||
if (Settings::Manager::getBool("terrain shadows", "Shadows"))
|
||||
if (Settings::shadows().mTerrainShadows)
|
||||
shadowCastingTraversalMask |= Mask_Terrain;
|
||||
|
||||
mShadowManager = std::make_unique<SceneUtil::ShadowManager>(sceneRoot, mRootNode, shadowCastingTraversalMask,
|
||||
indoorShadowCastingTraversalMask, Mask_Terrain | Mask_Object | Mask_Static,
|
||||
indoorShadowCastingTraversalMask, Mask_Terrain | Mask_Object | Mask_Static, Settings::shadows(),
|
||||
mResourceSystem->getSceneManager()->getShaderManager());
|
||||
|
||||
Shader::ShaderManager::DefineMap shadowDefines = mShadowManager->getShadowDefines();
|
||||
Shader::ShaderManager::DefineMap shadowDefines = mShadowManager->getShadowDefines(Settings::shadows());
|
||||
Shader::ShaderManager::DefineMap lightDefines = sceneRoot->getLightDefines();
|
||||
Shader::ShaderManager::DefineMap globalDefines
|
||||
= mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines();
|
||||
@ -770,7 +770,7 @@ namespace MWRender
|
||||
if (enabled)
|
||||
mShadowManager->enableOutdoorMode();
|
||||
else
|
||||
mShadowManager->enableIndoorMode();
|
||||
mShadowManager->enableIndoorMode(Settings::shadows());
|
||||
mPostProcessor->getStateUpdater()->setIsInterior(!enabled);
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ namespace
|
||||
camera->setNodeMask(MWRender::Mask_RenderToTexture);
|
||||
camera->setCullMask(MWRender::Mask_Sky);
|
||||
camera->addChild(mEarlyRenderBinRoot);
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(camera->getOrCreateStateSet());
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(Settings::shadows(), *camera->getOrCreateStateSet());
|
||||
}
|
||||
|
||||
private:
|
||||
@ -271,7 +271,7 @@ namespace MWRender
|
||||
if (!mSceneManager->getForceShaders())
|
||||
skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(),
|
||||
osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED | osg::StateAttribute::ON);
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(skyroot->getOrCreateStateSet());
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(Settings::shadows(), *skyroot->getOrCreateStateSet());
|
||||
parentNode->addChild(skyroot);
|
||||
|
||||
mEarlyRenderBinRoot = new osg::Group;
|
||||
|
@ -265,7 +265,8 @@ namespace MWRender
|
||||
camera->setNodeMask(Mask_RenderToTexture);
|
||||
|
||||
if (Settings::water().mRefractionScale != 1) // TODO: to be removed with issue #5709
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(camera->getOrCreateStateSet());
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(
|
||||
Settings::shadows(), *camera->getOrCreateStateSet());
|
||||
}
|
||||
|
||||
void apply(osg::Camera* camera) override
|
||||
@ -341,7 +342,7 @@ namespace MWRender
|
||||
camera->addChild(mClipCullNode);
|
||||
camera->setNodeMask(Mask_RenderToTexture);
|
||||
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(camera->getOrCreateStateSet());
|
||||
SceneUtil::ShadowManager::disableShadowsForStateSet(Settings::shadows(), *camera->getOrCreateStateSet());
|
||||
}
|
||||
|
||||
void apply(osg::Camera* camera) override
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <osgShadow/ShadowedScene>
|
||||
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/categories/shadows.hpp>
|
||||
#include <components/stereo/stereomanager.hpp>
|
||||
|
||||
#include "mwshadowtechnique.hpp"
|
||||
@ -13,9 +13,10 @@ namespace SceneUtil
|
||||
{
|
||||
using namespace osgShadow;
|
||||
|
||||
void ShadowManager::setupShadowSettings(Shader::ShaderManager& shaderManager)
|
||||
void ShadowManager::setupShadowSettings(
|
||||
const Settings::ShadowsCategory& settings, Shader::ShaderManager& shaderManager)
|
||||
{
|
||||
mEnableShadows = Settings::Manager::getBool("enable shadows", "Shadows");
|
||||
mEnableShadows = settings.mEnableShadows;
|
||||
|
||||
if (!mEnableShadows)
|
||||
{
|
||||
@ -28,64 +29,58 @@ namespace SceneUtil
|
||||
mShadowSettings->setLightNum(0);
|
||||
mShadowSettings->setReceivesShadowTraversalMask(~0u);
|
||||
|
||||
const int numberOfShadowMapsPerLight
|
||||
= std::clamp(Settings::Manager::getInt("number of shadow maps", "Shadows"), 1, 8);
|
||||
const int numberOfShadowMapsPerLight = settings.mNumberOfShadowMaps;
|
||||
|
||||
mShadowSettings->setNumShadowMapsPerLight(numberOfShadowMapsPerLight);
|
||||
mShadowSettings->setBaseShadowTextureUnit(shaderManager.reserveGlobalTextureUnits(
|
||||
Shader::ShaderManager::Slot::ShadowMaps, numberOfShadowMapsPerLight));
|
||||
|
||||
const float maximumShadowMapDistance = Settings::Manager::getFloat("maximum shadow map distance", "Shadows");
|
||||
const float maximumShadowMapDistance = settings.mMaximumShadowMapDistance;
|
||||
if (maximumShadowMapDistance > 0)
|
||||
{
|
||||
const float shadowFadeStart
|
||||
= std::clamp(Settings::Manager::getFloat("shadow fade start", "Shadows"), 0.f, 1.f);
|
||||
const float shadowFadeStart = settings.mShadowFadeStart;
|
||||
mShadowSettings->setMaximumShadowMapDistance(maximumShadowMapDistance);
|
||||
mShadowTechnique->setShadowFadeStart(maximumShadowMapDistance * shadowFadeStart);
|
||||
}
|
||||
|
||||
mShadowSettings->setMinimumShadowMapNearFarRatio(
|
||||
Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows"));
|
||||
mShadowSettings->setMinimumShadowMapNearFarRatio(settings.mMinimumLispsmNearFarRatio);
|
||||
|
||||
const std::string& computeSceneBounds = Settings::Manager::getString("compute scene bounds", "Shadows");
|
||||
const std::string& computeSceneBounds = settings.mComputeSceneBounds;
|
||||
if (Misc::StringUtils::ciEqual(computeSceneBounds, "primitives"))
|
||||
mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
|
||||
else if (Misc::StringUtils::ciEqual(computeSceneBounds, "bounds"))
|
||||
mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
|
||||
|
||||
int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows");
|
||||
const int mapres = settings.mShadowMapResolution;
|
||||
mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres));
|
||||
|
||||
mShadowTechnique->setSplitPointUniformLogarithmicRatio(
|
||||
Settings::Manager::getFloat("split point uniform logarithmic ratio", "Shadows"));
|
||||
mShadowTechnique->setSplitPointDeltaBias(Settings::Manager::getFloat("split point bias", "Shadows"));
|
||||
mShadowTechnique->setSplitPointUniformLogarithmicRatio(settings.mSplitPointUniformLogarithmicRatio);
|
||||
mShadowTechnique->setSplitPointDeltaBias(settings.mSplitPointBias);
|
||||
|
||||
mShadowTechnique->setPolygonOffset(Settings::Manager::getFloat("polygon offset factor", "Shadows"),
|
||||
Settings::Manager::getFloat("polygon offset units", "Shadows"));
|
||||
mShadowTechnique->setPolygonOffset(settings.mPolygonOffsetFactor, settings.mPolygonOffsetUnits);
|
||||
|
||||
if (Settings::Manager::getBool("use front face culling", "Shadows"))
|
||||
if (settings.mUseFrontFaceCulling)
|
||||
mShadowTechnique->enableFrontFaceCulling();
|
||||
else
|
||||
mShadowTechnique->disableFrontFaceCulling();
|
||||
|
||||
if (Settings::Manager::getBool("allow shadow map overlap", "Shadows"))
|
||||
if (settings.mAllowShadowMapOverlap)
|
||||
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::CASCADED);
|
||||
else
|
||||
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::PARALLEL_SPLIT);
|
||||
|
||||
if (Settings::Manager::getBool("enable debug hud", "Shadows"))
|
||||
if (settings.mEnableDebugHud)
|
||||
mShadowTechnique->enableDebugHUD();
|
||||
else
|
||||
mShadowTechnique->disableDebugHUD();
|
||||
}
|
||||
|
||||
void ShadowManager::disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateset)
|
||||
void ShadowManager::disableShadowsForStateSet(const Settings::ShadowsCategory& settings, osg::StateSet& stateset)
|
||||
{
|
||||
if (!Settings::Manager::getBool("enable shadows", "Shadows"))
|
||||
if (!settings.mEnableShadows)
|
||||
return;
|
||||
|
||||
const int numberOfShadowMapsPerLight
|
||||
= std::clamp(Settings::Manager::getInt("number of shadow maps", "Shadows"), 1, 8);
|
||||
const int numberOfShadowMapsPerLight = settings.mNumberOfShadowMaps;
|
||||
|
||||
int baseShadowTextureUnit = 8 - numberOfShadowMapsPerLight;
|
||||
|
||||
@ -99,18 +94,18 @@ namespace SceneUtil
|
||||
fakeShadowMapTexture->setShadowCompareFunc(osg::Texture::ShadowCompareFunc::ALWAYS);
|
||||
for (int i = baseShadowTextureUnit; i < baseShadowTextureUnit + numberOfShadowMapsPerLight; ++i)
|
||||
{
|
||||
stateset->setTextureAttributeAndModes(i, fakeShadowMapTexture,
|
||||
stateset.setTextureAttributeAndModes(i, fakeShadowMapTexture,
|
||||
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED);
|
||||
stateset->addUniform(
|
||||
stateset.addUniform(
|
||||
new osg::Uniform(("shadowTexture" + std::to_string(i - baseShadowTextureUnit)).c_str(), i));
|
||||
stateset->addUniform(
|
||||
stateset.addUniform(
|
||||
new osg::Uniform(("shadowTextureUnit" + std::to_string(i - baseShadowTextureUnit)).c_str(), i));
|
||||
}
|
||||
}
|
||||
|
||||
ShadowManager::ShadowManager(osg::ref_ptr<osg::Group> sceneRoot, osg::ref_ptr<osg::Group> rootNode,
|
||||
unsigned int outdoorShadowCastingMask, unsigned int indoorShadowCastingMask, unsigned int worldMask,
|
||||
Shader::ShaderManager& shaderManager)
|
||||
const Settings::ShadowsCategory& settings, Shader::ShaderManager& shaderManager)
|
||||
: mShadowedScene(new osgShadow::ShadowedScene)
|
||||
, mShadowTechnique(new MWShadowTechnique)
|
||||
, mOutdoorShadowCastingMask(outdoorShadowCastingMask)
|
||||
@ -126,7 +121,7 @@ namespace SceneUtil
|
||||
mShadowedScene->setNodeMask(sceneRoot->getNodeMask());
|
||||
|
||||
mShadowSettings = mShadowedScene->getShadowSettings();
|
||||
setupShadowSettings(shaderManager);
|
||||
setupShadowSettings(settings, shaderManager);
|
||||
|
||||
mShadowTechnique->setupCastingShader(shaderManager);
|
||||
mShadowTechnique->setWorldMask(worldMask);
|
||||
@ -140,7 +135,7 @@ namespace SceneUtil
|
||||
Stereo::Manager::instance().setShadowTechnique(nullptr);
|
||||
}
|
||||
|
||||
Shader::ShaderManager::DefineMap ShadowManager::getShadowDefines()
|
||||
Shader::ShaderManager::DefineMap ShadowManager::getShadowDefines(const Settings::ShadowsCategory& settings)
|
||||
{
|
||||
if (!mEnableShadows)
|
||||
return getShadowsDisabledDefines();
|
||||
@ -155,24 +150,19 @@ namespace SceneUtil
|
||||
definesWithShadows["shadow_texture_unit_list"] = definesWithShadows["shadow_texture_unit_list"].substr(
|
||||
0, definesWithShadows["shadow_texture_unit_list"].length() - 1);
|
||||
|
||||
definesWithShadows["shadowMapsOverlap"]
|
||||
= Settings::Manager::getBool("allow shadow map overlap", "Shadows") ? "1" : "0";
|
||||
definesWithShadows["shadowMapsOverlap"] = settings.mAllowShadowMapOverlap ? "1" : "0";
|
||||
|
||||
definesWithShadows["useShadowDebugOverlay"]
|
||||
= Settings::Manager::getBool("enable debug overlay", "Shadows") ? "1" : "0";
|
||||
definesWithShadows["useShadowDebugOverlay"] = settings.mEnableDebugOverlay ? "1" : "0";
|
||||
|
||||
// switch this to reading settings if it's ever exposed to the user
|
||||
definesWithShadows["perspectiveShadowMaps"]
|
||||
= mShadowSettings->getShadowMapProjectionHint() == ShadowSettings::PERSPECTIVE_SHADOW_MAP ? "1" : "0";
|
||||
|
||||
definesWithShadows["disableNormalOffsetShadows"]
|
||||
= Settings::Manager::getFloat("normal offset distance", "Shadows") == 0.0 ? "1" : "0";
|
||||
definesWithShadows["disableNormalOffsetShadows"] = settings.mNormalOffsetDistance == 0.0 ? "1" : "0";
|
||||
|
||||
definesWithShadows["shadowNormalOffset"]
|
||||
= std::to_string(Settings::Manager::getFloat("normal offset distance", "Shadows"));
|
||||
definesWithShadows["shadowNormalOffset"] = std::to_string(settings.mNormalOffsetDistance);
|
||||
|
||||
definesWithShadows["limitShadowMapDistance"]
|
||||
= Settings::Manager::getFloat("maximum shadow map distance", "Shadows") > 0 ? "1" : "0";
|
||||
definesWithShadows["limitShadowMapDistance"] = settings.mMaximumShadowMapDistance > 0 ? "1" : "0";
|
||||
|
||||
return definesWithShadows;
|
||||
}
|
||||
@ -200,9 +190,9 @@ namespace SceneUtil
|
||||
return definesWithoutShadows;
|
||||
}
|
||||
|
||||
void ShadowManager::enableIndoorMode()
|
||||
void ShadowManager::enableIndoorMode(const Settings::ShadowsCategory& settings)
|
||||
{
|
||||
if (Settings::Manager::getBool("enable indoor shadows", "Shadows"))
|
||||
if (settings.mEnableIndoorShadows)
|
||||
mShadowSettings->setCastsShadowTraversalMask(mIndoorShadowCastingMask);
|
||||
else
|
||||
mShadowTechnique->disableShadows(true);
|
||||
|
@ -8,32 +8,38 @@ namespace osg
|
||||
class StateSet;
|
||||
class Group;
|
||||
}
|
||||
|
||||
namespace osgShadow
|
||||
{
|
||||
class ShadowSettings;
|
||||
class ShadowedScene;
|
||||
}
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
struct ShadowsCategory;
|
||||
}
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
class MWShadowTechnique;
|
||||
class ShadowManager
|
||||
{
|
||||
public:
|
||||
static void disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateSet);
|
||||
static void disableShadowsForStateSet(const Settings::ShadowsCategory& settings, osg::StateSet& stateset);
|
||||
|
||||
static Shader::ShaderManager::DefineMap getShadowsDisabledDefines();
|
||||
|
||||
ShadowManager(osg::ref_ptr<osg::Group> sceneRoot, osg::ref_ptr<osg::Group> rootNode,
|
||||
explicit ShadowManager(osg::ref_ptr<osg::Group> sceneRoot, osg::ref_ptr<osg::Group> rootNode,
|
||||
unsigned int outdoorShadowCastingMask, unsigned int indoorShadowCastingMask, unsigned int worldMask,
|
||||
Shader::ShaderManager& shaderManager);
|
||||
const Settings::ShadowsCategory& settings, Shader::ShaderManager& shaderManager);
|
||||
~ShadowManager();
|
||||
|
||||
void setupShadowSettings(Shader::ShaderManager& shaderManager);
|
||||
void setupShadowSettings(const Settings::ShadowsCategory& settings, Shader::ShaderManager& shaderManager);
|
||||
|
||||
Shader::ShaderManager::DefineMap getShadowDefines();
|
||||
Shader::ShaderManager::DefineMap getShadowDefines(const Settings::ShadowsCategory& settings);
|
||||
|
||||
void enableIndoorMode();
|
||||
void enableIndoorMode(const Settings::ShadowsCategory& settings);
|
||||
|
||||
void enableOutdoorMode();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user