From 2147c18cf57d40c7f0978a0f2450e71732e364db Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Mon, 28 Jun 2021 00:11:31 +0100 Subject: [PATCH] Do not overwrite old removed state with old dummy state --- components/shader/shadervisitor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index b4455c4096..8a84dfc68b 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -402,9 +402,12 @@ namespace Shader { writableStateSet->addUniform(new osg::Uniform("alphaRef", reqs.mAlphaRef)); - const auto* alphaFunc = writableStateSet->getAttributePair(osg::StateAttribute::ALPHAFUNC); - if (alphaFunc) - removedState->setAttribute(alphaFunc->first, alphaFunc->second); + if (!removedState->getAttributePair(osg::StateAttribute::ALPHAFUNC)) + { + const auto* alphaFunc = writableStateSet->getAttributePair(osg::StateAttribute::ALPHAFUNC); + if (alphaFunc) + removedState->setAttribute(alphaFunc->first, alphaFunc->second); + } // This prevents redundant glAlphaFunc calls while letting the shadows bin still see the test writableStateSet->setAttribute(RemovedAlphaFunc::getInstance(reqs.mAlphaFunc), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);