mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
Separate indoor and outdoor shadow casting masks.
This commit is contained in:
parent
35eb71052e
commit
f9cf1ac94b
@ -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)
|
||||
|
@ -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<osg::Group> sceneRoot, osg::ref_ptr<osg::Group> rootNode) : mShadowedScene(new osgShadow::ShadowedScene),
|
||||
mShadowTechnique(new MWShadowTechnique)
|
||||
ShadowManager::ShadowManager(osg::ref_ptr<osg::Group> sceneRoot, osg::ref_ptr<osg::Group> 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);
|
||||
}
|
||||
}
|
||||
|
@ -15,16 +15,23 @@ namespace SceneUtil
|
||||
public:
|
||||
static void disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateSet);
|
||||
|
||||
ShadowManager(osg::ref_ptr<osg::Group> sceneRoot, osg::ref_ptr<osg::Group> rootNode);
|
||||
ShadowManager(osg::ref_ptr<osg::Group> sceneRoot, osg::ref_ptr<osg::Group> 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<osgShadow::ShadowedScene> mShadowedScene;
|
||||
osg::ref_ptr<osgShadow::ShadowSettings> mShadowSettings;
|
||||
osg::ref_ptr<MWShadowTechnique> mShadowTechnique;
|
||||
|
Loading…
Reference in New Issue
Block a user