Add a setting to control coverage adjustment

With it on, which was always the case before this setting was added,
vanilla content and poorly-made mods will look acceptable, but well-made
mods will have alpha-tested meshes appear to grow and potentially gain a
weird outline as they get further away.

With it off, which replicates the 0.46 behaviour, well-made mods will
look really good, but vanilla content and poorly-made mods will have
alpha-tested meshes shrink as they get further away.

It's been bugging me that this was forced on since 0.47 released, and
I'd hoped to figure out a solution for automatic detection at some point
before 0.48 branched off, but I didn't, so now this is what we're
getting to have Tamriel Rebuilt look right.
backport_gl_clamp_removal
AnyOldName3 1 year ago
parent fff497c205
commit 33e39a0360

@ -127,6 +127,7 @@ bool Launcher::AdvancedPage::loadSettings()
if (Settings::Manager::getInt("antialiasing", "Video") == 0) {
antialiasAlphaTestCheckBox->setCheckState(Qt::Unchecked);
}
loadSettingBool(adjustCoverageForAlphaTestCheckBox, "adjust coverage for alpha test", "Shaders");
loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
connect(animSourcesCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotAnimSourcesToggled(bool)));
loadSettingBool(animSourcesCheckBox, "use additional anim sources", "Game");
@ -281,6 +282,7 @@ void Launcher::AdvancedPage::saveSettings()
saveSettingBool(radialFogCheckBox, "radial fog", "Fog");
saveSettingBool(softParticlesCheckBox, "soft particles", "Shaders");
saveSettingBool(antialiasAlphaTestCheckBox, "antialias alpha test", "Shaders");
saveSettingBool(adjustCoverageForAlphaTestCheckBox, "adjust coverage for alpha test", "Shaders");
saveSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
saveSettingBool(animSourcesCheckBox, "use additional anim sources", "Game");
saveSettingBool(weaponSheathingCheckBox, "weapon sheathing", "Game");

@ -412,6 +412,7 @@ namespace MWRender
resourceSystem->getSceneManager()->setSpecularMapPattern(Settings::Manager::getString("specular map pattern", "Shaders"));
resourceSystem->getSceneManager()->setApplyLightingToEnvMaps(Settings::Manager::getBool("apply lighting to environment maps", "Shaders"));
resourceSystem->getSceneManager()->setConvertAlphaTestToAlphaToCoverage(Settings::Manager::getBool("antialias alpha test", "Shaders") && Settings::Manager::getInt("antialiasing", "Video") > 1);
resourceSystem->getSceneManager()->setAdjustCoverageForAlphaTest(Settings::Manager::getBool("adjust coverage for alpha test", "Shaders"));
// Let LightManager choose which backend to use based on our hint. For methods besides legacy lighting, this depends on support for various OpenGL extensions.
osg::ref_ptr<SceneUtil::LightManager> sceneRoot = new SceneUtil::LightManager(lightingMethod == SceneUtil::LightingMethod::FFP);

@ -346,6 +346,7 @@ namespace Resource
, mApplyLightingToEnvMaps(false)
, mLightingMethod(SceneUtil::LightingMethod::FFP)
, mConvertAlphaTestToAlphaToCoverage(false)
, mAdjustCoverageForAlphaTest(false)
, mSupportsNormalsRT(false)
, mSharedStateManager(new SharedStateManager)
, mImageManager(imageManager)
@ -456,6 +457,11 @@ namespace Resource
mConvertAlphaTestToAlphaToCoverage = convert;
}
void SceneManager::setAdjustCoverageForAlphaTest(bool adjustCoverage)
{
mAdjustCoverageForAlphaTest = adjustCoverage;
}
void SceneManager::setOpaqueDepthTex(osg::ref_ptr<osg::Texture> texturePing, osg::ref_ptr<osg::Texture> texturePong)
{
mOpaqueDepthTex = { texturePing, texturePong };
@ -1046,6 +1052,7 @@ namespace Resource
shaderVisitor->setSpecularMapPattern(mSpecularMapPattern);
shaderVisitor->setApplyLightingToEnvMaps(mApplyLightingToEnvMaps);
shaderVisitor->setConvertAlphaTestToAlphaToCoverage(mConvertAlphaTestToAlphaToCoverage);
shaderVisitor->setAdjustCoverageForAlphaTest(mAdjustCoverageForAlphaTest);
shaderVisitor->setSupportsNormalsRT(mSupportsNormalsRT);
return shaderVisitor;
}

@ -123,6 +123,7 @@ namespace Resource
SceneUtil::LightingMethod getLightingMethod() const;
void setConvertAlphaTestToAlphaToCoverage(bool convert);
void setAdjustCoverageForAlphaTest(bool adjustCoverage);
void setShaderPath(const std::string& path);
@ -217,6 +218,7 @@ namespace Resource
SceneUtil::LightingMethod mLightingMethod;
SceneUtil::LightManager::SupportedMethods mSupportedLightingMethods;
bool mConvertAlphaTestToAlphaToCoverage;
bool mAdjustCoverageForAlphaTest;
bool mSupportsNormalsRT;
std::array<osg::ref_ptr<osg::Texture>, 2> mOpaqueDepthTex;
bool mSoftParticles = false;

@ -170,6 +170,7 @@ namespace Shader
, mAutoUseSpecularMaps(false)
, mApplyLightingToEnvMaps(false)
, mConvertAlphaTestToAlphaToCoverage(false)
, mAdjustCoverageForAlphaTest(false)
, mSupportsNormalsRT(false)
, mShaderManager(shaderManager)
, mImageManager(imageManager)
@ -614,7 +615,7 @@ namespace Shader
// 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)
if (mAdjustCoverageForAlphaTest && !reqs.mAlphaBlend)
defineMap["adjustCoverage"] = "1";
// Preventing alpha tested stuff shrinking as lower mip levels are used requires knowing the texture size
@ -929,6 +930,11 @@ namespace Shader
mConvertAlphaTestToAlphaToCoverage = convert;
}
void ShaderVisitor::setAdjustCoverageForAlphaTest(bool adjustCoverage)
{
mAdjustCoverageForAlphaTest = adjustCoverage;
}
ReinstateRemovedStateVisitor::ReinstateRemovedStateVisitor(bool allowedToModifyStateSets)
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
, mAllowedToModifyStateSets(allowedToModifyStateSets)

@ -47,6 +47,7 @@ namespace Shader
void setApplyLightingToEnvMaps(bool apply);
void setConvertAlphaTestToAlphaToCoverage(bool convert);
void setAdjustCoverageForAlphaTest(bool adjustCoverage);
void setSupportsNormalsRT(bool supports) { mSupportsNormalsRT = supports; }
@ -74,6 +75,7 @@ namespace Shader
bool mApplyLightingToEnvMaps;
bool mConvertAlphaTestToAlphaToCoverage;
bool mAdjustCoverageForAlphaTest;
bool mSupportsNormalsRT;

@ -259,6 +259,19 @@ Convert the alpha test (cutout/punchthrough alpha) to alpha-to-coverage when :re
This allows MSAA to work with alpha-tested meshes, producing better-looking edges without pixelation.
When MSAA is off, this setting will have no visible effect, but might have a performance cost.
adjust coverage for alpha test
------------------------------
:Type: boolean
:Range: True/False
:Default: True
Attempt to simulate coverage-preserving mipmaps in textures created without them which are used for alpha testing anyway.
This will somewhat mitigate these objects appearing to shrink as they get further from the camera, but isn't perfect.
Better results can be achieved by generating more appropriate mipmaps in the first place, but if this workaround is used with such textures, affected objects will appear to grow as they get further from the camera.
It is recommended that mod authors specify how this setting should be set, and mod users follow their advice.
soft particles
--------------

@ -487,6 +487,12 @@ minimum interior brightness = 0.08
# When MSAA is off, this setting will have no visible effect, but might have a performance cost.
antialias alpha test = false
# Attempt to simulate coverage-preserving mipmaps in textures created without them which are used for alpha testing anyway.
# This will somewhat mitigate these objects appearing to shrink as they get further from the camera, but isn't perfect.
# Better results can be achieved by generating more appropriate mipmaps in the first place, but if this workaround is used with such textures, affected objects will appear to grow as they get further from the camera.
# It is recommended that mod authors specify how this setting should be set, and mod users follow their advice.
adjust coverage for alpha test = true
# Soften intersection of blended particle systems with opaque geometry
soft particles = false

@ -455,7 +455,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="softParticlesCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enables soft particles for particle effects. This technique softens the intersection between individual particles and other opaque geometry by blending between them.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -465,6 +465,16 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="adjustCoverageForAlphaTestCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Simulate coverage-preserving mipmaps to prevent alpha-tested meshes shrinking as they get further away. Will cause meshes whose textures have coverage-preserving mipmaps to grow, though, so refer to mod installation instructions for how to set this.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Adjust coverage for alpha test</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

Loading…
Cancel
Save