mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Unconditionally disable alpha testing when shaders are used
This commit is contained in:
parent
11b4af49ce
commit
8c3a786e54
@ -374,39 +374,40 @@ namespace Shader
|
|||||||
writableStateSet->addUniform(new osg::Uniform("colorMode", reqs.mColorMode));
|
writableStateSet->addUniform(new osg::Uniform("colorMode", reqs.mColorMode));
|
||||||
|
|
||||||
defineMap["alphaFunc"] = std::to_string(reqs.mAlphaFunc);
|
defineMap["alphaFunc"] = std::to_string(reqs.mAlphaFunc);
|
||||||
|
|
||||||
|
// back up removed state in case recreateShaders gets rid of the shader later
|
||||||
|
osg::ref_ptr<osg::StateSet> removedState;
|
||||||
|
if ((removedState = getRemovedState(*writableStateSet)) && !mAllowedToModifyStateSets)
|
||||||
|
removedState = new osg::StateSet(*removedState, osg::CopyOp::SHALLOW_COPY);
|
||||||
|
if (!removedState)
|
||||||
|
removedState = new osg::StateSet();
|
||||||
|
|
||||||
if (reqs.mAlphaFunc != osg::AlphaFunc::ALWAYS)
|
if (reqs.mAlphaFunc != osg::AlphaFunc::ALWAYS)
|
||||||
{
|
{
|
||||||
writableStateSet->addUniform(new osg::Uniform("alphaRef", reqs.mAlphaRef));
|
writableStateSet->addUniform(new osg::Uniform("alphaRef", reqs.mAlphaRef));
|
||||||
|
|
||||||
// back up removed state in case recreateShaders gets rid of the shader later
|
|
||||||
osg::ref_ptr<osg::StateSet> removedState;
|
|
||||||
if ((removedState = getRemovedState(*writableStateSet)) && !mAllowedToModifyStateSets)
|
|
||||||
removedState = new osg::StateSet(*removedState, osg::CopyOp::SHALLOW_COPY);
|
|
||||||
if (!removedState)
|
|
||||||
removedState = new osg::StateSet();
|
|
||||||
|
|
||||||
if (writableStateSet->getMode(GL_ALPHA_TEST) != osg::StateAttribute::INHERIT)
|
|
||||||
removedState->setMode(GL_ALPHA_TEST, writableStateSet->getMode(GL_ALPHA_TEST));
|
|
||||||
// This disables the deprecated fixed-function alpha test
|
|
||||||
writableStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
|
|
||||||
|
|
||||||
const auto* alphaFunc = writableStateSet->getAttributePair(osg::StateAttribute::ALPHAFUNC);
|
const auto* alphaFunc = writableStateSet->getAttributePair(osg::StateAttribute::ALPHAFUNC);
|
||||||
if (alphaFunc)
|
if (alphaFunc)
|
||||||
removedState->setAttribute(alphaFunc->first, alphaFunc->second);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (!removedState->getModeList().empty() || !removedState->getAttributeList().empty())
|
if (writableStateSet->getMode(GL_ALPHA_TEST) != osg::StateAttribute::INHERIT)
|
||||||
{
|
removedState->setMode(GL_ALPHA_TEST, writableStateSet->getMode(GL_ALPHA_TEST));
|
||||||
// user data is normally shallow copied so shared with the original stateset
|
// This disables the deprecated fixed-function alpha test
|
||||||
osg::ref_ptr<osg::UserDataContainer> writableUserData;
|
writableStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
|
||||||
if (mAllowedToModifyStateSets)
|
|
||||||
writableUserData = writableStateSet->getOrCreateUserDataContainer();
|
|
||||||
else
|
|
||||||
writableUserData = getWritableUserDataContainer(*writableStateSet);
|
|
||||||
|
|
||||||
updateRemovedState(*writableUserData, removedState);
|
if (!removedState->getModeList().empty() || !removedState->getAttributeList().empty())
|
||||||
}
|
{
|
||||||
|
// user data is normally shallow copied so shared with the original stateset
|
||||||
|
osg::ref_ptr<osg::UserDataContainer> writableUserData;
|
||||||
|
if (mAllowedToModifyStateSets)
|
||||||
|
writableUserData = writableStateSet->getOrCreateUserDataContainer();
|
||||||
|
else
|
||||||
|
writableUserData = getWritableUserDataContainer(*writableStateSet);
|
||||||
|
|
||||||
|
updateRemovedState(*writableUserData, removedState);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Shader> vertexShader (mShaderManager.getShader(mDefaultVsTemplate, defineMap, osg::Shader::VERTEX));
|
osg::ref_ptr<osg::Shader> vertexShader (mShaderManager.getShader(mDefaultVsTemplate, defineMap, osg::Shader::VERTEX));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user