diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 920c7278ce..5971de9662 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -202,7 +202,7 @@ namespace MWRender mSceneRoot = sceneRoot; sceneRoot->setStartLight(1); - int shadowCastingTraversalMask = Mask_Scene; + int shadowCastingTraversalMask = 0; if (Settings::Manager::getBool("actor shadows", "Shadows")) shadowCastingTraversalMask |= Mask_Actor; if (Settings::Manager::getBool("player shadows", "Shadows")) @@ -210,8 +210,7 @@ namespace MWRender if (Settings::Manager::getBool("terrain shadows", "Shadows")) shadowCastingTraversalMask |= Mask_Terrain; - mShadowManager.reset(new SceneUtil::ShadowManager(sceneRoot, mRootNode)); - mShadowManager->setupShadowSettings(shadowCastingTraversalMask); + mShadowManager.reset(new SceneUtil::ShadowManager(sceneRoot, mRootNode, Mask_Scene | shadowCastingTraversalMask, shadowCastingTraversalMask)); Shader::ShaderManager::DefineMap shadowDefines = mShadowManager->getShadowDefines(); Shader::ShaderManager::DefineMap globalDefines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines(); @@ -462,6 +461,10 @@ namespace MWRender void RenderingManager::setSkyEnabled(bool enabled) { mSky->setEnabled(enabled); + if (enabled) + mShadowManager->enableOutdoorMode(); + else + mShadowManager->enableIndoorMode(); } bool RenderingManager::toggleRenderMode(RenderMode mode) diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index 9d25b57646..00e6b93a99 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -13,7 +13,7 @@ namespace SceneUtil { using namespace osgShadow; - void ShadowManager::setupShadowSettings(int castsShadowMask) + void ShadowManager::setupShadowSettings() { mEnableShadows = Settings::Manager::getBool("enable shadows", "Shadows"); @@ -26,7 +26,6 @@ namespace SceneUtil mShadowTechnique->enableShadows(); mShadowSettings->setLightNum(0); - mShadowSettings->setCastsShadowTraversalMask(castsShadowMask); mShadowSettings->setReceivesShadowTraversalMask(~0u); int numberOfShadowMapsPerLight = Settings::Manager::getInt("number of shadow maps", "Shadows"); @@ -64,8 +63,10 @@ namespace SceneUtil stateset->setTextureAttributeAndModes(i, fakeShadowMapTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED); } - ShadowManager::ShadowManager(osg::ref_ptr sceneRoot, osg::ref_ptr rootNode) : mShadowedScene(new osgShadow::ShadowedScene), - mShadowTechnique(new MWShadowTechnique) + ShadowManager::ShadowManager(osg::ref_ptr sceneRoot, osg::ref_ptr rootNode, unsigned int outdoorShadowCastingMask, unsigned int indoorShadowCastingMask) : mShadowedScene(new osgShadow::ShadowedScene), + mShadowTechnique(new MWShadowTechnique), + mOutdoorShadowCastingMask(outdoorShadowCastingMask), + mIndoorShadowCastingMask(indoorShadowCastingMask) { mShadowedScene->setShadowTechnique(mShadowTechnique); @@ -73,6 +74,9 @@ namespace SceneUtil rootNode->addChild(mShadowedScene); mShadowSettings = mShadowedScene->getShadowSettings(); + setupShadowSettings(); + + enableOutdoorMode(); } Shader::ShaderManager::DefineMap ShadowManager::getShadowDefines() @@ -98,4 +102,12 @@ namespace SceneUtil return definesWithShadows; } + void ShadowManager::enableIndoorMode() + { + mShadowSettings->setCastsShadowTraversalMask(mIndoorShadowCastingMask); + } + void ShadowManager::enableOutdoorMode() + { + mShadowSettings->setCastsShadowTraversalMask(mOutdoorShadowCastingMask); + } } diff --git a/components/sceneutil/shadow.hpp b/components/sceneutil/shadow.hpp index 2936941ff3..61a564a2a8 100644 --- a/components/sceneutil/shadow.hpp +++ b/components/sceneutil/shadow.hpp @@ -15,16 +15,23 @@ namespace SceneUtil public: static void disableShadowsForStateSet(osg::ref_ptr stateSet); - ShadowManager(osg::ref_ptr sceneRoot, osg::ref_ptr rootNode); + ShadowManager(osg::ref_ptr sceneRoot, osg::ref_ptr rootNode, unsigned int outdoorShadowCastingMask, unsigned int indoorShadowCastingMask); - virtual void setupShadowSettings(int castsShadowMask); + virtual void setupShadowSettings(); virtual Shader::ShaderManager::DefineMap getShadowDefines(); virtual Shader::ShaderManager::DefineMap getShadowsDisabledDefines(); + + virtual void enableIndoorMode(); + + virtual void enableOutdoorMode(); protected: bool mEnableShadows; + unsigned int mOutdoorShadowCastingMask; + unsigned int mIndoorShadowCastingMask; + osg::ref_ptr mShadowedScene; osg::ref_ptr mShadowSettings; osg::ref_ptr mShadowTechnique;