1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 19:06:42 +00:00

Prettify shadow define map setup.

This commit is contained in:
AnyOldName3 2019-01-31 20:12:17 +00:00
parent abe9ba736e
commit 2761a38562

View file

@ -103,27 +103,20 @@ namespace SceneUtil
return getShadowsDisabledDefines(); return getShadowsDisabledDefines();
Shader::ShaderManager::DefineMap definesWithShadows; Shader::ShaderManager::DefineMap definesWithShadows;
definesWithShadows.insert(std::make_pair(std::string("shadows_enabled"), std::string("1")));
definesWithShadows["shadows_enabled"] = "1";
for (unsigned int i = 0; i < mShadowSettings->getNumShadowMapsPerLight(); ++i) for (unsigned int i = 0; i < mShadowSettings->getNumShadowMapsPerLight(); ++i)
definesWithShadows["shadow_texture_unit_list"] += std::to_string(i) + ","; definesWithShadows["shadow_texture_unit_list"] += std::to_string(i) + ",";
// remove extra comma // remove extra comma
definesWithShadows["shadow_texture_unit_list"] = definesWithShadows["shadow_texture_unit_list"].substr(0, definesWithShadows["shadow_texture_unit_list"].length() - 1); definesWithShadows["shadow_texture_unit_list"] = definesWithShadows["shadow_texture_unit_list"].substr(0, definesWithShadows["shadow_texture_unit_list"].length() - 1);
if (Settings::Manager::getBool("allow shadow map overlap", "Shadows")) definesWithShadows["shadowMapsOverlap"] = Settings::Manager::getBool("allow shadow map overlap", "Shadows") ? "1" : "0";
definesWithShadows["shadowMapsOverlap"] = "1";
else
definesWithShadows["shadowMapsOverlap"] = "0";
if (Settings::Manager::getBool("enable debug overlay", "Shadows")) definesWithShadows["useShadowDebugOverlay"] = Settings::Manager::getBool("enable debug overlay", "Shadows") ? "1" : "0";
definesWithShadows["useShadowDebugOverlay"] = "1";
else
definesWithShadows["useShadowDebugOverlay"] = "0";
// switch this to reading settings if it's ever exposed to the user // switch this to reading settings if it's ever exposed to the user
if (mShadowSettings->getShadowMapProjectionHint() == ShadowSettings::PERSPECTIVE_SHADOW_MAP) definesWithShadows["perspectiveShadowMaps"] = mShadowSettings->getShadowMapProjectionHint() == ShadowSettings::PERSPECTIVE_SHADOW_MAP ? "1" : "0";
definesWithShadows["perspectiveShadowMaps"] = "1";
else
definesWithShadows["perspectiveShadowMaps"] = "0";
definesWithShadows["disableNormalOffsetShadows"] = Settings::Manager::getFloat("normal offset distance", "Shadows") == 0.0 ? "1" : "0"; definesWithShadows["disableNormalOffsetShadows"] = Settings::Manager::getFloat("normal offset distance", "Shadows") == 0.0 ? "1" : "0";
@ -135,7 +128,9 @@ namespace SceneUtil
Shader::ShaderManager::DefineMap ShadowManager::getShadowsDisabledDefines() Shader::ShaderManager::DefineMap ShadowManager::getShadowsDisabledDefines()
{ {
Shader::ShaderManager::DefineMap definesWithoutShadows; Shader::ShaderManager::DefineMap definesWithoutShadows;
definesWithoutShadows.insert(std::make_pair(std::string("shadows_enabled"), std::string("0")));
definesWithoutShadows["shadows_enabled"] = "0";
definesWithoutShadows["shadow_texture_unit_list"] = ""; definesWithoutShadows["shadow_texture_unit_list"] = "";
definesWithoutShadows["shadowMapsOverlap"] = "0"; definesWithoutShadows["shadowMapsOverlap"] = "0";
@ -150,6 +145,7 @@ namespace SceneUtil
return definesWithoutShadows; return definesWithoutShadows;
} }
void ShadowManager::enableIndoorMode() void ShadowManager::enableIndoorMode()
{ {
if (Settings::Manager::getBool("enable indoor shadows", "Shadows")) if (Settings::Manager::getBool("enable indoor shadows", "Shadows"))
@ -157,6 +153,7 @@ namespace SceneUtil
else else
mShadowTechnique->disableShadows(); mShadowTechnique->disableShadows();
} }
void ShadowManager::enableOutdoorMode() void ShadowManager::enableOutdoorMode()
{ {
if (mEnableShadows) if (mEnableShadows)