From df7d2e46c01aabe8cafc552cefceaea7d4552dc3 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 25 Aug 2022 22:34:50 +0100 Subject: [PATCH] Added a uniform to indicate whether rendering is occurring in a reflection --- apps/openmw/mwrender/renderingmanager.cpp | 1 + apps/openmw/mwrender/water.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 1385147c4c..947384000e 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -173,6 +173,7 @@ namespace MWRender stateset->addUniform(new osg::Uniform("far", 0.f)); stateset->addUniform(new osg::Uniform("skyBlendingStart", 0.f)); stateset->addUniform(new osg::Uniform("screenRes", osg::Vec2f{})); + stateset->addUniform(new osg::Uniform("isReflection", false)); if (mUsePlayerUniforms) { stateset->addUniform(new osg::Uniform("windSpeed", 0.0f)); diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 159380b786..0f67a333ab 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -351,6 +351,9 @@ public: camera->setName("ReflectionCamera"); camera->addCullCallback(new InheritViewPointCallback); + // Inform the shader that we're in a reflection + camera->getOrCreateStateSet()->addUniform(new osg::Uniform("isReflection", true)); + // XXX: should really flip the FrontFace on each renderable instead of forcing clockwise. osg::ref_ptr frontFace(new osg::FrontFace); frontFace->setMode(osg::FrontFace::CLOCKWISE); @@ -474,7 +477,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem geom2->setNodeMask(Mask_SimpleWater); geom2->setName("Simple Water Geometry"); mWaterNode->addChild(geom2); - + mSceneRoot->addChild(mWaterNode); setHeight(mTop); @@ -701,7 +704,7 @@ void Water::createShaderWaterStateSet(osg::Node* node, Reflection* reflection, R normalMap->setMaxAnisotropy(16); normalMap->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR); normalMap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); - + mRainIntensityUpdater = new RainIntensityUpdater(); node->setUpdateCallback(mRainIntensityUpdater);