1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-31 13:06:42 +00:00

Correct behaviour of use front face culling setting to not use back face culling either when disabled.

This commit is contained in:
AnyOldName3 2019-02-01 00:29:13 +00:00
parent cfe921fb82
commit 15547750ba

View file

@ -849,7 +849,7 @@ void SceneUtil::MWShadowTechnique::disableFrontFaceCulling()
_useFrontFaceCulling = false; _useFrontFaceCulling = false;
if (_shadowCastingStateSet) if (_shadowCastingStateSet)
_shadowCastingStateSet->removeAttribute(osg::StateAttribute::CULLFACE); _shadowCastingStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
} }
void SceneUtil::MWShadowTechnique::setupCastingShader(Shader::ShaderManager & shaderManager) void SceneUtil::MWShadowTechnique::setupCastingShader(Shader::ShaderManager & shaderManager)
@ -1462,6 +1462,7 @@ void MWShadowTechnique::createShaders()
// In this case we will draw them in their entirety. // In this case we will draw them in their entirety.
if (_useFrontFaceCulling) if (_useFrontFaceCulling)
{
_shadowCastingStateSet->setAttribute(new osg::CullFace(osg::CullFace::FRONT), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); _shadowCastingStateSet->setAttribute(new osg::CullFace(osg::CullFace::FRONT), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
// make sure GL_CULL_FACE is off by default // make sure GL_CULL_FACE is off by default
@ -1469,6 +1470,9 @@ void MWShadowTechnique::createShaders()
// it will also set cull face mode ON so no need for override // it will also set cull face mode ON so no need for override
_shadowCastingStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF); _shadowCastingStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
} }
else
_shadowCastingStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
}
_polygonOffset = new osg::PolygonOffset(_polygonOffsetFactor, _polygonOffsetUnits); _polygonOffset = new osg::PolygonOffset(_polygonOffsetFactor, _polygonOffsetUnits);
_shadowCastingStateSet->setAttribute(_polygonOffset.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); _shadowCastingStateSet->setAttribute(_polygonOffset.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);