mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-29 03:19:44 +00:00
Disable coverage adjustment for blended objects
This commit is contained in:
parent
e42b3bf960
commit
84a9facedf
@ -904,6 +904,7 @@ void SceneUtil::MWShadowTechnique::setupCastingShader(Shader::ShaderManager & sh
|
||||
program->addShader(castingVertexShader);
|
||||
program->addShader(shaderManager.getShader("shadowcasting_fragment.glsl", { {"alphaFunc", std::to_string(alphaFunc)},
|
||||
{"alphaToCoverage", "0"},
|
||||
{"adjustCoverage", "1"},
|
||||
{"useGPUShader4", useGPUShader4}
|
||||
}, osg::Shader::FRAGMENT));
|
||||
}
|
||||
|
@ -482,6 +482,7 @@ namespace Shader
|
||||
removedState = new osg::StateSet();
|
||||
|
||||
defineMap["alphaToCoverage"] = "0";
|
||||
defineMap["adjustCoverage"] = "0";
|
||||
if (reqs.mAlphaFunc != osg::AlphaFunc::ALWAYS)
|
||||
{
|
||||
writableStateSet->addUniform(new osg::Uniform("alphaRef", reqs.mAlphaRef));
|
||||
@ -505,6 +506,11 @@ namespace Shader
|
||||
defineMap["alphaToCoverage"] = "1";
|
||||
}
|
||||
|
||||
// Adjusting coverage isn't safe with blending on as blending requires the alpha to be intact.
|
||||
// Maybe we could also somehow (e.g. userdata) detect when the diffuse map has coverage-preserving mip maps in the future
|
||||
if (!reqs.mAlphaBlend)
|
||||
defineMap["adjustCoverage"] = "1";
|
||||
|
||||
// Preventing alpha tested stuff shrinking as lower mip levels are used requires knowing the texture size
|
||||
osg::ref_ptr<osg::GLExtensions> exts = osg::GLExtensions::Get(0, false);
|
||||
if (exts && exts->isGpuShader4Supported)
|
||||
|
@ -22,7 +22,7 @@ float mipmapLevel(vec2 scaleduv)
|
||||
|
||||
float coveragePreservingAlphaScale(sampler2D diffuseMap, vec2 uv)
|
||||
{
|
||||
#if @alphaFunc != FUNC_ALWAYS && @alphaFunc != FUNC_NEVER
|
||||
#if @adjustCoverage
|
||||
vec2 textureSize;
|
||||
#if @useGPUShader4
|
||||
textureSize = textureSize2D(diffuseMap, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user