From 0c4c092b9fa6d673e67e9ac3d054b6e91b7d1a7d Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 8 Oct 2021 19:55:57 +0100 Subject: [PATCH] Sky dome: Enable depth test but mask depth changes On VR with visibility masking the depth buffer is first set to the nearest possible value in parts of the frame that won't be visible through the VR headset's lenses. This is meant to reduce GPU fragment load. The sky dome however is rendered with depth testing disabled which bypasses the visibility masking. To allow invisible parts of the sky dome to be culled, enable depth testing but set the depth mask to false to prevent modification of the depth buffer. --- simgear/scene/sky/dome.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/simgear/scene/sky/dome.cxx b/simgear/scene/sky/dome.cxx index 5304a36b..15e45ac7 100644 --- a/simgear/scene/sky/dome.cxx +++ b/simgear/scene/sky/dome.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -143,11 +144,12 @@ SGSkyDome::build( double hscale, double vscale, simgear::SGReaderWriterOptions * stateSet->setAttributeAndModes(shadeModel); stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); stateSet->setMode(GL_FOG, osg::StateAttribute::OFF); - stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); + stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON); stateSet->setMode(GL_BLEND, osg::StateAttribute::OFF); stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF); + stateSet->setAttribute(new osg::Depth(osg::Depth::LESS, 0, 1, false)); stateSet->setAttribute(new osg::CullFace(osg::CullFace::BACK)); osg::Material* material = new osg::Material;