From 158f4e23cbf05e4424c8fc37c949f017522c67c9 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 25 Apr 2019 19:25:04 +0300 Subject: [PATCH 1/3] Make sure forcePPL and clamp are defined in the editor --- apps/opencs/model/world/data.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index b9208b44b..fb1a023f7 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -75,6 +76,11 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat mResourcesManager.setVFS(mVFS.get()); mResourceSystem.reset(new Resource::ResourceSystem(mVFS.get())); + Shader::ShaderManager::DefineMap defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines(); + defines["forcePPL"] = "0"; + defines["clamp"] = "1"; + mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines); + mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string()); int index = 0; From 9f9b7cb0ae9ca410a052870704a1363dda0e1e6a Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 25 Apr 2019 20:38:58 +0300 Subject: [PATCH 2/3] Init shadow defines in the editor too for a good measure --- apps/opencs/model/world/data.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index fb1a023f7..c22f3e220 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -79,6 +79,13 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat Shader::ShaderManager::DefineMap defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines(); defines["forcePPL"] = "0"; defines["clamp"] = "1"; + defines["shadows_enabled"] = "0"; + defines["shadow_texture_unit_list"] = ""; + defines["shadowMapsOverlap"] = "0"; + defines["useShadowDebugOverlay"] = "0"; + defines["perspectiveShadowMaps"] = "0"; + defines["disableNormalOffsetShadows"] = "0"; + defines["shadowNormalOffset"] = "0.0"; mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines); mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string()); From 05d94d35f9d720646d432924e6468280596eda81 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 29 Apr 2019 19:31:46 +0300 Subject: [PATCH 3/3] Make disabled shadow defines map static --- apps/opencs/model/world/data.cpp | 11 ++++------- components/sceneutil/shadow.hpp | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index c22f3e220..bc630806a 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -77,15 +78,11 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat mResourceSystem.reset(new Resource::ResourceSystem(mVFS.get())); Shader::ShaderManager::DefineMap defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines(); + Shader::ShaderManager::DefineMap shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines(); defines["forcePPL"] = "0"; defines["clamp"] = "1"; - defines["shadows_enabled"] = "0"; - defines["shadow_texture_unit_list"] = ""; - defines["shadowMapsOverlap"] = "0"; - defines["useShadowDebugOverlay"] = "0"; - defines["perspectiveShadowMaps"] = "0"; - defines["disableNormalOffsetShadows"] = "0"; - defines["shadowNormalOffset"] = "0.0"; + for (const auto& define : shadowDefines) + defines[define.first] = define.second; mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines); mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string()); diff --git a/components/sceneutil/shadow.hpp b/components/sceneutil/shadow.hpp index 24deff253..928de4543 100644 --- a/components/sceneutil/shadow.hpp +++ b/components/sceneutil/shadow.hpp @@ -15,6 +15,8 @@ namespace SceneUtil public: static void disableShadowsForStateSet(osg::ref_ptr stateSet); + static Shader::ShaderManager::DefineMap getShadowsDisabledDefines(); + ShadowManager(osg::ref_ptr sceneRoot, osg::ref_ptr rootNode, unsigned int outdoorShadowCastingMask, unsigned int indoorShadowCastingMask, Shader::ShaderManager &shaderManager); virtual ~ShadowManager() = default; @@ -23,8 +25,6 @@ namespace SceneUtil virtual Shader::ShaderManager::DefineMap getShadowDefines(); - virtual Shader::ShaderManager::DefineMap getShadowsDisabledDefines(); - virtual void enableIndoorMode(); virtual void enableOutdoorMode();