diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 6dad8129c..a21bc549a 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -675,18 +675,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) Settings::Manager::getInt("anisotropy", "General") ); - // geometry shader must be enabled before the RenderingManager sets up any shaders - // therefore this part is separate from the rest of stereo setup. - mStereoEnabled = mEnvironment.getVrMode() || Settings::Manager::getBool("stereo enabled", "Stereo"); - if (mStereoEnabled) - { - // Mask in everything that does not currently use shaders. - // Remove that altogether when the sky finally uses them. - auto noShaderMask = MWRender::VisMask::Mask_Sky | MWRender::VisMask::Mask_Sun | MWRender::VisMask::Mask_WeatherParticles; - // Since shaders are not yet created, we need to use the brute force technique initially - mStereoView.reset(new Misc::StereoView(noShaderMask, MWRender::VisMask::Mask_Scene)); - } - int numThreads = Settings::Manager::getInt("preload num threads", "Cells"); if (numThreads <= 0) throw std::runtime_error("Invalid setting: 'preload num threads' must be >0"); @@ -782,6 +770,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) #ifdef USE_OPENXR mXrEnvironment.setGUIManager(new MWVR::VRGUIManager(mViewer, mResourceSystem.get(), rootNode)); mXrEnvironment.getViewer()->configureCallbacks(); + mStereoView->setCullMask(mStereoView->getCullMask() & ~MWRender::VisMask::Mask_GUI); #endif @@ -816,7 +805,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) // Stereo shader technique can be set up now. mStereoView->setStereoTechnique(Misc::getStereoTechnique()); mStereoView->initializeScene(); - mStereoView->setCullMask(mStereoView->getCullMask()); + mStereoView->setCullMask(mViewer->getCamera()->getCullMask() & ~MWRender::VisMask::Mask_GUI); } window->setStore(mEnvironment.getWorld()->getStore()); @@ -935,6 +924,22 @@ void OMW::Engine::go() // Create encoder mEncoder = new ToUTF8::Utf8Encoder(mEncoding); +#ifdef USE_OPENXR + mEnvironment.setVrMode(true); +#endif + + // geometry shader must be enabled before the RenderingManager sets up any shaders + // therefore this part is separate from the rest of stereo setup. + mStereoEnabled = mEnvironment.getVrMode() || Settings::Manager::getBool("stereo enabled", "Stereo"); + if (mStereoEnabled) + { + // Mask in everything that does not currently use shaders. + // Remove that altogether when the sky finally uses them. + auto noShaderMask = MWRender::VisMask::Mask_Sky | MWRender::VisMask::Mask_Sun | MWRender::VisMask::Mask_WeatherParticles; + // Since shaders are not yet created, we need to use the brute force technique initially + mStereoView.reset(new Misc::StereoView(noShaderMask, MWRender::VisMask::Mask_Scene)); + } + // Setup viewer mViewer = new osgViewer::Viewer; mViewer->setReleaseContextAtEndOfFrameHint(false); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 873401029..6aeb9123f 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -606,11 +606,15 @@ namespace MWGui mOldCullMask = mViewer->getCamera()->getCullMask(); mViewer->getUpdateVisitor()->setTraversalMask(disablemask); mViewer->getCamera()->setCullMask(disablemask); + mViewer->getCamera()->setCullMaskLeft(disablemask); + mViewer->getCamera()->setCullMaskRight(disablemask); } else if (enable && mViewer->getCamera()->getCullMask() == disablemask) { mViewer->getUpdateVisitor()->setTraversalMask(mOldUpdateMask); mViewer->getCamera()->setCullMask(mOldCullMask); + mViewer->getCamera()->setCullMaskLeft(mOldCullMask); + mViewer->getCamera()->setCullMaskRight(mOldCullMask); } } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index d1d48a7b2..6e4106399 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -369,7 +369,10 @@ namespace MWRender mViewer->getCamera()->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR); mViewer->getCamera()->setCullingMode(cullingMode); - mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater)); + auto mask = ~(Mask_UpdateVisitor | Mask_SimpleWater); + mViewer->getCamera()->setCullMask(mask); + mViewer->getCamera()->setCullMaskLeft(mask); + mViewer->getCamera()->setCullMaskRight(mask); NifOsg::Loader::setHiddenNodeMask(Mask_UpdateVisitor); NifOsg::Loader::setIntersectionDisabledNodeMask(Mask_Effect); Nif::NIFFile::setLoadUnsupportedFiles(Settings::Manager::getBool("load unsupported nif files", "Models")); @@ -586,6 +589,8 @@ namespace MWRender else mask &= ~Mask_Scene; mViewer->getCamera()->setCullMask(mask); + mViewer->getCamera()->setCullMaskLeft(mask); + mViewer->getCamera()->setCullMaskRight(mask); return enabled; } else if (mode == Render_NavMesh) diff --git a/apps/openmw/vrengine.cpp b/apps/openmw/vrengine.cpp index 5bba71a61..2ecc17ed6 100644 --- a/apps/openmw/vrengine.cpp +++ b/apps/openmw/vrengine.cpp @@ -14,7 +14,6 @@ void OMW::Engine::initVr() if (!mViewer) throw std::logic_error("mViewer must be initialized before calling initVr()"); - mEnvironment.setVrMode(true); mXrEnvironment.setManager(new MWVR::OpenXRManager); mXrEnvironment.setSession(new MWVR::VRSession()); mXrEnvironment.setViewer(new MWVR::VRViewer(mViewer)); diff --git a/components/misc/stereo.cpp b/components/misc/stereo.cpp index af521321e..19656546f 100644 --- a/components/misc/stereo.cpp +++ b/components/misc/stereo.cpp @@ -720,6 +720,8 @@ namespace Misc else { mMainCamera->setCullMask(cullMask); + mMainCamera->setCullMaskLeft(cullMask); + mMainCamera->setCullMaskRight(cullMask); } } osg::Node::NodeMask StereoView::getCullMask()