From 5433ecf861d0ac56b1e6a7e6f87eaf17cbfa7a2a Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sat, 23 Nov 2024 05:47:45 +0300 Subject: [PATCH] Change default depth test mode to <= (#7040) --- CHANGELOG.md | 1 + apps/components_tests/nifosg/testnifloader.cpp | 1 + apps/openmw/mwrender/skyutil.cpp | 3 +-- components/nifosg/nifloader.cpp | 3 +-- components/resource/scenemanager.cpp | 4 ++-- components/sceneutil/depth.hpp | 4 +++- components/sceneutil/extradata.cpp | 3 ++- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97941564a3..5576d41a0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ Bug #6993: Shooting your last round of ammunition causes the attack animation to cancel Bug #7009: Falling actors teleport to the ground without receiving any damage on cell loading Bug #7034: Misc items defined in one content file are not treated as keys if another content file uses them as such + Bug #7040: Incorrect rendering order for Rebirth's Stormfang Bug #7042: Weapon follow animations that immediately follow the hit animations cause multiple hits Bug #7044: Changing a class' services does not affect autocalculated NPCs Bug #7053: Running into objects doesn't trigger GetCollidingPC diff --git a/apps/components_tests/nifosg/testnifloader.cpp b/apps/components_tests/nifosg/testnifloader.cpp index fa023fff0d..90b8d5c26a 100644 --- a/apps/components_tests/nifosg/testnifloader.cpp +++ b/apps/components_tests/nifosg/testnifloader.cpp @@ -221,6 +221,7 @@ osg::Group { AttributeList 1 { osg::Depth { UniqueID 10 + Function LEQUAL } Value OFF } diff --git a/apps/openmw/mwrender/skyutil.cpp b/apps/openmw/mwrender/skyutil.cpp index 2881f51d4c..dacf628a2c 100644 --- a/apps/openmw/mwrender/skyutil.cpp +++ b/apps/openmw/mwrender/skyutil.cpp @@ -885,12 +885,11 @@ namespace MWRender osg::StateSet* queryStateSet = new osg::StateSet; if (queryVisible) { - osg::ref_ptr depth = new SceneUtil::AutoDepth(osg::Depth::LEQUAL); + osg::ref_ptr depth = new SceneUtil::AutoDepth; // This is a trick to make fragments written by the query always use the maximum depth value, // without having to retrieve the current far clipping distance. // We want the sun glare to be "infinitely" far away. double far = SceneUtil::AutoDepth::isReversed() ? 0.0 : 1.0; - depth->setFunction(osg::Depth::LEQUAL); depth->setZNear(far); depth->setZFar(far); depth->setWriteMask(false); diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index bf63415b63..d817ed2c9f 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -2011,7 +2010,7 @@ namespace NifOsg stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); return; } - osg::ref_ptr depth = new osg::Depth; + osg::ref_ptr depth = new SceneUtil::AutoDepth; depth->setWriteMask(depthWrite); if (!depthTest) depth->setFunction(osg::Depth::ALWAYS); diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 82a77ccc0a..cbda399120 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -275,14 +275,14 @@ namespace Resource { if (stateset->getRenderingHint() == osg::StateSet::TRANSPARENT_BIN) { - osg::ref_ptr depth = new osg::Depth; + osg::ref_ptr depth = new SceneUtil::AutoDepth; depth->setWriteMask(false); stateset->setAttributeAndModes(depth, osg::StateAttribute::ON); } else if (stateset->getRenderingHint() == osg::StateSet::OPAQUE_BIN) { - osg::ref_ptr depth = new osg::Depth; + osg::ref_ptr depth = new SceneUtil::AutoDepth; depth->setWriteMask(true); stateset->setAttributeAndModes(depth, osg::StateAttribute::ON); diff --git a/components/sceneutil/depth.hpp b/components/sceneutil/depth.hpp index ccc214ae3e..a9f99b145f 100644 --- a/components/sceneutil/depth.hpp +++ b/components/sceneutil/depth.hpp @@ -64,7 +64,9 @@ namespace SceneUtil { public: AutoDepth( - osg::Depth::Function func = osg::Depth::LESS, double zNear = 0.0, double zFar = 1.0, bool writeMask = true) + // NB: OSG uses LESS test function by default, Morrowind uses LEQUAL + osg::Depth::Function func = osg::Depth::LEQUAL, double zNear = 0.0, double zFar = 1.0, + bool writeMask = true) { setFunction(func); setZNear(zNear); diff --git a/components/sceneutil/extradata.cpp b/components/sceneutil/extradata.cpp index e616880697..2d00980565 100644 --- a/components/sceneutil/extradata.cpp +++ b/components/sceneutil/extradata.cpp @@ -18,7 +18,8 @@ namespace SceneUtil { void setupSoftEffect(osg::Node& node, float size, bool falloff, float falloffDepth) { - static const osg::ref_ptr depth = new SceneUtil::AutoDepth(osg::Depth::LESS, 0, 1, false); + static const osg::ref_ptr depth + = new SceneUtil::AutoDepth(osg::Depth::LEQUAL, 0, 1, false); osg::StateSet* stateset = node.getOrCreateStateSet();