From ce0e937e8d2c654ad3280604024d619e443785a1 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 1 Nov 2017 18:22:59 +0000 Subject: [PATCH 1/3] Attempt to force the sky to not accept the default shadow shader or shadow texture. --- apps/openmw/mwrender/sky.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 6c599fc3fa..4256f6987b 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -1122,7 +1122,8 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana skyroot->setName("Sky Root"); // Assign empty program to specify we don't want shaders // The shaders generated by the SceneManager can't handle everything we need - skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE); + skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::PROTECTED|osg::StateAttribute::ON); + skyroot->getOrCreateStateSet()->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF); skyroot->setNodeMask(Mask_Sky); parentNode->addChild(skyroot); From 7a03ad65584451a63b5db47885d4265bebd6ae89 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Sun, 5 Nov 2017 14:46:03 +0000 Subject: [PATCH 2/3] Switch to a tidier way of disabling the correct texture unit --- apps/openmw/mwrender/renderingmanager.cpp | 2 +- apps/openmw/mwrender/shadow.hpp | 2 ++ apps/openmw/mwrender/sky.cpp | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index aa5240618a..bdabdaeabb 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -210,7 +210,7 @@ namespace MWRender settings->setReceivesShadowTraversalMask(~0u); //settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::PERSPECTIVE_SHADOW_MAP); - settings->setBaseShadowTextureUnit(7); + settings->setBaseShadowTextureUnit(MWShadow::baseShadowTextureUnit); //settings->setMinimumShadowMapNearFarRatio(0); //settings->setNumShadowMapsPerLight(1); //settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::ORTHOGRAPHIC_SHADOW_MAP); diff --git a/apps/openmw/mwrender/shadow.hpp b/apps/openmw/mwrender/shadow.hpp index a941f9c2e6..4e1725c7fe 100644 --- a/apps/openmw/mwrender/shadow.hpp +++ b/apps/openmw/mwrender/shadow.hpp @@ -10,6 +10,8 @@ namespace MWRender public: MWShadow(); + const static int baseShadowTextureUnit = 7; + virtual void cull(osgUtil::CullVisitor& cv); protected: const int debugTextureUnit; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 4256f6987b..9f4542ae9c 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -48,6 +48,7 @@ #include "vismask.hpp" #include "renderbin.hpp" +#include "shadow.hpp" namespace { @@ -1123,7 +1124,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana // Assign empty program to specify we don't want shaders // The shaders generated by the SceneManager can't handle everything we need skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::PROTECTED|osg::StateAttribute::ON); - skyroot->getOrCreateStateSet()->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF); + skyroot->getOrCreateStateSet()->setTextureMode(MWShadow::baseShadowTextureUnit, GL_TEXTURE_2D, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF); skyroot->setNodeMask(Mask_Sky); parentNode->addChild(skyroot); From 3106159721239e59cf9d2229dd62bd792554c33f Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 7 Nov 2017 16:40:32 +0000 Subject: [PATCH 3/3] Turn off all shadow texture units for the sky now it is possible for there to be more than one --- apps/openmw/mwrender/sky.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 9f4542ae9c..8eec3f30b2 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -1124,7 +1124,8 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana // Assign empty program to specify we don't want shaders // The shaders generated by the SceneManager can't handle everything we need skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::PROTECTED|osg::StateAttribute::ON); - skyroot->getOrCreateStateSet()->setTextureMode(MWShadow::baseShadowTextureUnit, GL_TEXTURE_2D, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF); + for (int i = MWShadow::baseShadowTextureUnit; i < MWShadow::baseShadowTextureUnit + MWShadow::numberOfShadowMapsPerLight; ++i) + skyroot->getOrCreateStateSet()->setTextureMode(i, GL_TEXTURE_2D, osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF); skyroot->setNodeMask(Mask_Sky); parentNode->addChild(skyroot);