mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-26 11:37:12 +00:00
Disable A2C for alpha-blended drawables
This commit is contained in:
parent
f2eed5594a
commit
e3fd5efcfe
@ -26,8 +26,10 @@ namespace Shader
|
|||||||
, mColorMode(0)
|
, mColorMode(0)
|
||||||
, mMaterialOverridden(false)
|
, mMaterialOverridden(false)
|
||||||
, mAlphaTestOverridden(false)
|
, mAlphaTestOverridden(false)
|
||||||
|
, mAlphaBlendOverridden(false)
|
||||||
, mAlphaFunc(GL_ALWAYS)
|
, mAlphaFunc(GL_ALWAYS)
|
||||||
, mAlphaRef(1.0)
|
, mAlphaRef(1.0)
|
||||||
|
, mAlphaBlend(false)
|
||||||
, mNormalHeight(false)
|
, mNormalHeight(false)
|
||||||
, mTexStageRequiringTangents(-1)
|
, mTexStageRequiringTangents(-1)
|
||||||
, mNode(nullptr)
|
, mNode(nullptr)
|
||||||
@ -330,6 +332,15 @@ namespace Shader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int alphaBlend = stateset->getMode(GL_BLEND);
|
||||||
|
if (alphaBlend != osg::StateAttribute::INHERIT && (!mRequirements.back().mAlphaBlendOverridden || alphaBlend & osg::StateAttribute::PROTECTED))
|
||||||
|
{
|
||||||
|
if (alphaBlend & osg::StateAttribute::OVERRIDE)
|
||||||
|
mRequirements.back().mAlphaBlendOverridden = true;
|
||||||
|
|
||||||
|
mRequirements.back().mAlphaBlend = alphaBlend & osg::StateAttribute::ON;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderVisitor::pushRequirements(osg::Node& node)
|
void ShaderVisitor::pushRequirements(osg::Node& node)
|
||||||
@ -394,7 +405,8 @@ namespace Shader
|
|||||||
// 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 (mConvertAlphaTestToAlphaToCoverage)
|
// Blending won't work with A2C as we use the alpha channel for coverage. gl_SampleCoverage from ARB_sample_shading would save the day, but requires GLSL 130
|
||||||
|
if (mConvertAlphaTestToAlphaToCoverage && !reqs.mAlphaBlend)
|
||||||
{
|
{
|
||||||
writableStateSet->setMode(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, osg::StateAttribute::ON);
|
writableStateSet->setMode(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, osg::StateAttribute::ON);
|
||||||
defineMap["alphaToCoverage"] = "1";
|
defineMap["alphaToCoverage"] = "1";
|
||||||
|
@ -84,9 +84,11 @@ namespace Shader
|
|||||||
|
|
||||||
bool mMaterialOverridden;
|
bool mMaterialOverridden;
|
||||||
bool mAlphaTestOverridden;
|
bool mAlphaTestOverridden;
|
||||||
|
bool mAlphaBlendOverridden;
|
||||||
|
|
||||||
GLenum mAlphaFunc;
|
GLenum mAlphaFunc;
|
||||||
float mAlphaRef;
|
float mAlphaRef;
|
||||||
|
bool mAlphaBlend;
|
||||||
|
|
||||||
bool mNormalHeight; // true if normal map has height info in alpha channel
|
bool mNormalHeight; // true if normal map has height info in alpha channel
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user