mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 10:21:11 +00:00
Merge branch 'alpha-test-override' into 'master'
Ensure original (removed) state overrides replacement state when recreating shaders Closes #6108 See merge request OpenMW/openmw!966
This commit is contained in:
commit
07a7a903a7
@ -275,10 +275,12 @@ namespace Shader
|
|||||||
osg::StateSet::AttributeList removedAttributes;
|
osg::StateSet::AttributeList removedAttributes;
|
||||||
if (osg::ref_ptr<osg::StateSet> removedState = getRemovedState(*stateset))
|
if (osg::ref_ptr<osg::StateSet> removedState = getRemovedState(*stateset))
|
||||||
removedAttributes = removedState->getAttributeList();
|
removedAttributes = removedState->getAttributeList();
|
||||||
for (const auto& attributeMap : { attributes, removedAttributes })
|
for (const auto* attributeMap : std::initializer_list<const osg::StateSet::AttributeList*>{ &attributes, &removedAttributes })
|
||||||
{
|
{
|
||||||
for (osg::StateSet::AttributeList::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it)
|
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)
|
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
|
// This should probably be moved out of ShaderRequirements and be applied directly now it's a uniform instead of a define
|
||||||
@ -400,9 +402,12 @@ namespace Shader
|
|||||||
{
|
{
|
||||||
writableStateSet->addUniform(new osg::Uniform("alphaRef", reqs.mAlphaRef));
|
writableStateSet->addUniform(new osg::Uniform("alphaRef", reqs.mAlphaRef));
|
||||||
|
|
||||||
const auto* alphaFunc = writableStateSet->getAttributePair(osg::StateAttribute::ALPHAFUNC);
|
if (!removedState->getAttributePair(osg::StateAttribute::ALPHAFUNC))
|
||||||
if (alphaFunc)
|
{
|
||||||
removedState->setAttribute(alphaFunc->first, alphaFunc->second);
|
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
|
// 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);
|
writableStateSet->setAttribute(RemovedAlphaFunc::getInstance(reqs.mAlphaFunc), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user