mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-17 01:10:10 +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(castingVertexShader);
|
||||||
program->addShader(shaderManager.getShader("shadowcasting_fragment.glsl", { {"alphaFunc", std::to_string(alphaFunc)},
|
program->addShader(shaderManager.getShader("shadowcasting_fragment.glsl", { {"alphaFunc", std::to_string(alphaFunc)},
|
||||||
{"alphaToCoverage", "0"},
|
{"alphaToCoverage", "0"},
|
||||||
|
{"adjustCoverage", "1"},
|
||||||
{"useGPUShader4", useGPUShader4}
|
{"useGPUShader4", useGPUShader4}
|
||||||
}, osg::Shader::FRAGMENT));
|
}, osg::Shader::FRAGMENT));
|
||||||
}
|
}
|
||||||
|
@ -482,6 +482,7 @@ namespace Shader
|
|||||||
removedState = new osg::StateSet();
|
removedState = new osg::StateSet();
|
||||||
|
|
||||||
defineMap["alphaToCoverage"] = "0";
|
defineMap["alphaToCoverage"] = "0";
|
||||||
|
defineMap["adjustCoverage"] = "0";
|
||||||
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));
|
||||||
@ -505,6 +506,11 @@ namespace Shader
|
|||||||
defineMap["alphaToCoverage"] = "1";
|
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
|
// 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);
|
osg::ref_ptr<osg::GLExtensions> exts = osg::GLExtensions::Get(0, false);
|
||||||
if (exts && exts->isGpuShader4Supported)
|
if (exts && exts->isGpuShader4Supported)
|
||||||
|
@ -22,7 +22,7 @@ float mipmapLevel(vec2 scaleduv)
|
|||||||
|
|
||||||
float coveragePreservingAlphaScale(sampler2D diffuseMap, vec2 uv)
|
float coveragePreservingAlphaScale(sampler2D diffuseMap, vec2 uv)
|
||||||
{
|
{
|
||||||
#if @alphaFunc != FUNC_ALWAYS && @alphaFunc != FUNC_NEVER
|
#if @adjustCoverage
|
||||||
vec2 textureSize;
|
vec2 textureSize;
|
||||||
#if @useGPUShader4
|
#if @useGPUShader4
|
||||||
textureSize = textureSize2D(diffuseMap, 0);
|
textureSize = textureSize2D(diffuseMap, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user