From 8a1b4bde8ab8b918e4ac570c54e1afbdef9499a5 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Sun, 27 Jun 2021 00:12:07 +0100 Subject: [PATCH] Ensure original (removed) state overrides replacement state when recreating shaders When the shader visitor replaces state (e.g. changes the deprecated alpha test to a shader-based one) it backs up the original state. If shaders are recreated, we need to know what the canonical state was and create shaders to implement that instead of creating shaders to implement dummy replacement state. This was actually usually working as the removed state got checked after the active state, so overwrote anything derived from it. However, if the active state had the override bit set, that would make it override the removed state. Skipping any active state that duplicates removed state fixes this case. Resolves #6108 --- components/shader/shadervisitor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index 3c5898b873..d51dbfa6b9 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -279,6 +279,8 @@ namespace Shader { for (osg::StateSet::AttributeList::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it) { + if (attributeMap != removedAttributes && removedAttributes.count(it->first)) + continue; if (it->first.first == osg::StateAttribute::MATERIAL) { // This should probably be moved out of ShaderRequirements and be applied directly now it's a uniform instead of a define