From aa31cbba4ffba8630ce80f8ec25333c81984aa48 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 8 Nov 2017 01:20:52 +0000 Subject: [PATCH] Attempt (and fail) to make the local map show without unwanted shadow --- apps/openmw/mwrender/localmap.cpp | 8 ++++++++ components/shader/shadermanager.cpp | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index b78c4dcd2c..4b60a7cf22 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -23,6 +23,7 @@ #include "../mwworld/cellstore.hpp" #include "vismask.hpp" +#include "shadow.hpp" namespace { @@ -201,6 +202,13 @@ osg::ref_ptr LocalMap::createOrthographicCamera(float x, float y, f lightSource->setStateSetModes(*stateset, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); + osg::ref_ptr fakeShadowMapImage = new osg::Image(); + fakeShadowMapImage->allocateImage(1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT); + *(float*)fakeShadowMapImage->data() = -std::numeric_limits::infinity(); // this has been tried both positive and negative + osg::ref_ptr fakeShadowMapTexture = new osg::Texture2D(fakeShadowMapImage); + for (int i = MWShadow::baseShadowTextureUnit; i < MWShadow::baseShadowTextureUnit + MWShadow::numberOfShadowMapsPerLight; ++i) + stateset->setTextureAttributeAndModes(i, fakeShadowMapTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED); + camera->addChild(lightSource); camera->setStateSet(stateset); camera->setViewport(0, 0, mMapResolution, mMapResolution); diff --git a/components/shader/shadermanager.cpp b/components/shader/shadermanager.cpp index 02488dd42b..93b0168ae7 100644 --- a/components/shader/shadermanager.cpp +++ b/components/shader/shadermanager.cpp @@ -11,6 +11,8 @@ #include #include +#include "apps/openmw/mwrender/shadow.hpp" + namespace Shader { @@ -106,7 +108,7 @@ namespace Shader // set up shadows in the shader // get these values from settings manager bool shadows = true & !disableShadows; - int numShadowMaps = 2; + int numShadowMaps = MWRender::MWShadow::numberOfShadowMapsPerLight; DefineMap definesWithShadows; if (shadows) {