Skip to content

Commit

Permalink
Merge branch 'deepasapuddle' into 'master'
Browse files Browse the repository at this point in the history
Change the default depth test mode from less-than to less-than-or-equal-to (#7040)

Closes #7040

See merge request OpenMW/openmw!4464
  • Loading branch information
jvoisin committed Nov 25, 2024
2 parents 9351a0e + 5433ecf commit b555c98
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions apps/components_tests/nifosg/testnifloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ osg::Group {
AttributeList 1 {
osg::Depth {
UniqueID 10
Function LEQUAL
}
Value OFF
}
Expand Down
3 changes: 1 addition & 2 deletions apps/openmw/mwrender/skyutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,12 +885,11 @@ namespace MWRender
osg::StateSet* queryStateSet = new osg::StateSet;
if (queryVisible)
{
osg::ref_ptr<osg::Depth> depth = new SceneUtil::AutoDepth(osg::Depth::LEQUAL);
osg::ref_ptr<osg::Depth> 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);
Expand Down
3 changes: 1 addition & 2 deletions components/nifosg/nifloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include <osg/AlphaFunc>
#include <osg/BlendFunc>
#include <osg/Depth>
#include <osg/FrontFace>
#include <osg/Material>
#include <osg/PolygonMode>
Expand Down Expand Up @@ -2011,7 +2010,7 @@ namespace NifOsg
stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
return;
}
osg::ref_ptr<osg::Depth> depth = new osg::Depth;
osg::ref_ptr<osg::Depth> depth = new SceneUtil::AutoDepth;
depth->setWriteMask(depthWrite);
if (!depthTest)
depth->setFunction(osg::Depth::ALWAYS);
Expand Down
4 changes: 2 additions & 2 deletions components/resource/scenemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ namespace Resource
{
if (stateset->getRenderingHint() == osg::StateSet::TRANSPARENT_BIN)
{
osg::ref_ptr<osg::Depth> depth = new osg::Depth;
osg::ref_ptr<osg::Depth> depth = new SceneUtil::AutoDepth;
depth->setWriteMask(false);

stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
}
else if (stateset->getRenderingHint() == osg::StateSet::OPAQUE_BIN)
{
osg::ref_ptr<osg::Depth> depth = new osg::Depth;
osg::ref_ptr<osg::Depth> depth = new SceneUtil::AutoDepth;
depth->setWriteMask(true);

stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
Expand Down
4 changes: 3 additions & 1 deletion components/sceneutil/depth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion components/sceneutil/extradata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace SceneUtil
{
void setupSoftEffect(osg::Node& node, float size, bool falloff, float falloffDepth)
{
static const osg::ref_ptr<SceneUtil::AutoDepth> depth = new SceneUtil::AutoDepth(osg::Depth::LESS, 0, 1, false);
static const osg::ref_ptr<SceneUtil::AutoDepth> depth
= new SceneUtil::AutoDepth(osg::Depth::LEQUAL, 0, 1, false);

osg::StateSet* stateset = node.getOrCreateStateSet();

Expand Down

0 comments on commit b555c98

Please sign in to comment.