mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 16:15:31 +00:00
Fix sunglare on Mesa
The sunglare works by comparing an occlusion query with depth testing on against one with depth testing off to determine if there's anything closer to the camera than the maximum depth buffer value. For the depth- tested query, the depth range is set from 1 to 1 so it's always drawn at the maximum distance. Originally, we had the depth function set to LESS, meaning that the query would always fail as 1 is not less than 1, but also glPolygonOffset was used to move the query by "the smallest value that is guaranteed to produce a resolvable offset for a given implementation" closer to the camera. While other driver and hardware combinations do that, Mesa seems to be clamping to the depth range, so still failing. Instead, it's simpler to just get rid of the polygon offset and change the depth test to LEQUAL as 1 *is* less than or equal to 1, but not than any other possible depth buffer value.
This commit is contained in:
parent
d1e8c6b223
commit
162b25c180
1 changed files with 1 additions and 3 deletions
|
@ -497,8 +497,6 @@ public:
|
|||
// Disable writing to the color buffer. We are using this geometry for visibility tests only.
|
||||
osg::ref_ptr<osg::ColorMask> colormask (new osg::ColorMask(0, 0, 0, 0));
|
||||
stateset->setAttributeAndModes(colormask, osg::StateAttribute::ON);
|
||||
osg::ref_ptr<osg::PolygonOffset> po (new osg::PolygonOffset( -1., -1. ));
|
||||
stateset->setAttributeAndModes(po, osg::StateAttribute::ON);
|
||||
|
||||
mTransform->addChild(queryNode);
|
||||
|
||||
|
@ -595,7 +593,7 @@ private:
|
|||
if (queryVisible)
|
||||
{
|
||||
osg::ref_ptr<osg::Depth> depth (new osg::Depth);
|
||||
depth->setFunction(osg::Depth::LESS);
|
||||
depth->setFunction(osg::Depth::LEQUAL);
|
||||
// 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.
|
||||
|
|
Loading…
Reference in a new issue