From dc33eeadf1b3e58ef76f85d339bbfcb13d1862dd Mon Sep 17 00:00:00 2001 From: bzzt Date: Fri, 21 Jun 2019 13:37:00 +0000 Subject: [PATCH] tightscenebound is uncessary after water bbfix --- apps/openmw/mwgui/loadingscreen.cpp | 10 ----- apps/openmw/mwgui/windowmanagerimp.cpp | 38 ++++++++++++++----- apps/openmw/mwgui/windowmanagerimp.hpp | 4 ++ apps/openmw/mwrender/renderingmanager.cpp | 8 ++-- components/sceneutil/shadow.cpp | 3 ++ components/sceneutil/waterutil.cpp | 8 ++++ .../reference/modding/settings/shadows.rst | 3 +- files/settings-default.cfg | 4 +- 8 files changed, 49 insertions(+), 29 deletions(-) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 093a2f34cf..dcfe723f77 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -334,12 +334,6 @@ namespace MWGui setupCopyFramebufferToTextureCallback(); } - // Turn off rendering except the GUI - int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask(); - int oldCullMask = mViewer->getCamera()->getCullMask(); - mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile); - mViewer->getCamera()->setCullMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile); - MWBase::Environment::get().getInputManager()->update(0, true, true); //osg::Timer timer; @@ -355,10 +349,6 @@ namespace MWGui //if (mViewer->getIncrementalCompileOperation()) //std::cout << "num to compile " << mViewer->getIncrementalCompileOperation()->getToCompile().size() << std::endl; - // resume 3d rendering - mViewer->getUpdateVisitor()->setTraversalMask(oldUpdateMask); - mViewer->getCamera()->setCullMask(oldCullMask); - mLastRenderTime = mTimer.time_m(); } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index d10270d77e..28521ac6fa 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -130,7 +130,9 @@ namespace MWGui osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& userDataPath) - : mStore(nullptr) + : mOldUpdateMask(0) + , mOldCullMask(0) + , mStore(nullptr) , mResourceSystem(resourceSystem) , mWorkQueue(workQueue) , mViewer(viewer) @@ -676,13 +678,34 @@ namespace MWGui } } + void WindowManager::enableScene(bool enable) + { + unsigned int disablemask = MWRender::Mask_GUI|MWRender::Mask_PreCompile; + if (!enable && mViewer->getCamera()->getCullMask() != disablemask) + { + mOldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask(); + mOldCullMask = mViewer->getCamera()->getCullMask(); + mViewer->getUpdateVisitor()->setTraversalMask(disablemask); + mViewer->getCamera()->setCullMask(disablemask); + } + else if (enable && mViewer->getCamera()->getCullMask() == disablemask) + { + mViewer->getUpdateVisitor()->setTraversalMask(mOldUpdateMask); + mViewer->getCamera()->setCullMask(mOldCullMask); + } + } + void WindowManager::updateVisible() { + bool loading = (getMode() == GM_Loading || getMode() == GM_LoadingWallpaper); + + bool mainmenucover = containsMode(GM_MainMenu) && MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame; + + enableScene(!loading && !mainmenucover); + if (!mMap) return; // UI not created yet - bool loading = (getMode() == GM_Loading || getMode() == GM_LoadingWallpaper); - mHud->setVisible(mHudEnabled && !loading); mToolTips->setVisible(mHudEnabled && !loading); @@ -1876,11 +1899,7 @@ namespace MWGui mVideoBackground->eventKeyButtonPressed += MyGUI::newDelegate(this, &WindowManager::onVideoKeyPressed); } - // Turn off all rendering except for the GUI - int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask(); - int oldCullMask = mViewer->getCamera()->getCullMask(); - mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI); - mViewer->getCamera()->setCullMask(MWRender::Mask_GUI); + enableScene(false); MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize(); sizeVideo(screenSize.width, screenSize.height); @@ -1936,8 +1955,7 @@ namespace MWGui setCursorVisible(cursorWasVisible); // Restore normal rendering - mViewer->getUpdateVisitor()->setTraversalMask(oldUpdateMask); - mViewer->getCamera()->setCullMask(oldCullMask); + updateVisible(); mVideoBackground->setVisible(false); } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 0b4307ec49..4e90f2e930 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -390,6 +390,8 @@ namespace MWGui virtual bool injectKeyRelease(MyGUI::KeyCode key); private: + unsigned int mOldUpdateMask; unsigned int mOldCullMask; + const MWWorld::ESMStore* mStore; Resource::ResourceSystem* mResourceSystem; osg::ref_ptr mWorkQueue; @@ -560,6 +562,8 @@ namespace MWGui void setMenuTransparency(float value); void updatePinnedWindows(); + + void enableScene(bool enable); }; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c966a5d67a..e631a8fd8b 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -235,6 +235,8 @@ namespace MWRender sceneRoot->setLightingMask(Mask_Lighting); mSceneRoot = sceneRoot; sceneRoot->setStartLight(1); + sceneRoot->setNodeMask(Mask_Scene); + sceneRoot->setName("Scene Root"); int shadowCastingTraversalMask = Mask_Scene; if (Settings::Manager::getBool("actor shadows", "Shadows")) @@ -347,9 +349,6 @@ namespace MWRender defaultMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(0.f, 0.f, 0.f, 0.f)); sceneRoot->getOrCreateStateSet()->setAttribute(defaultMat); - sceneRoot->setNodeMask(Mask_Scene); - sceneRoot->setName("Scene Root"); - mSky.reset(new SkyManager(sceneRoot, resourceSystem->getSceneManager())); mSky->setCamera(mViewer->getCamera()); @@ -768,11 +767,10 @@ namespace MWRender void waitTillDone() { - mMutex.lock(); + OpenThreads::ScopedLock lock(mMutex); if (mDone) return; mCondition.wait(&mMutex); - mMutex.unlock(); } mutable OpenThreads::Condition mCondition; diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index 6b88adaab2..a1cd1d660b 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -40,6 +40,8 @@ namespace SceneUtil mShadowSettings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows")); if (Settings::Manager::getBool("compute tight scene bounds", "Shadows")) mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES); + else + mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres)); @@ -95,6 +97,7 @@ namespace SceneUtil mShadowedScene->addChild(sceneRoot); rootNode->addChild(mShadowedScene); + mShadowedScene->setNodeMask(sceneRoot->getNodeMask()); mShadowSettings = mShadowedScene->getShadowSettings(); setupShadowSettings(); diff --git a/components/sceneutil/waterutil.cpp b/components/sceneutil/waterutil.cpp index 562b0ee730..20a50a9308 100644 --- a/components/sceneutil/waterutil.cpp +++ b/components/sceneutil/waterutil.cpp @@ -7,6 +7,12 @@ namespace SceneUtil { + // disable nonsense test against a worldsize bb what will always pass + class WaterBoundCallback : public osg::Drawable::ComputeBoundingBoxCallback + { + virtual osg::BoundingBox computeBound(const osg::Drawable&) const { return osg::BoundingBox(); } + }; + osg::ref_ptr createWaterGeometry(float size, int segments, float textureRepeats) { osg::ref_ptr verts (new osg::Vec3Array); @@ -51,6 +57,8 @@ namespace SceneUtil waterGeom->setNormalArray(normal, osg::Array::BIND_OVERALL); waterGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,verts->size())); + waterGeom->setComputeBoundingBoxCallback(new WaterBoundCallback); + waterGeom->setCullingActive(false); return waterGeom; } diff --git a/docs/source/reference/modding/settings/shadows.rst b/docs/source/reference/modding/settings/shadows.rst index 5854b6a917..638349ee6f 100644 --- a/docs/source/reference/modding/settings/shadows.rst +++ b/docs/source/reference/modding/settings/shadows.rst @@ -85,10 +85,9 @@ compute tight scene bounds :Type: boolean :Range: True/False -:Default: True +:Default: False With this setting enabled, attempt to better use the shadow map(s) by making them cover a smaller area. -This can be especially helpful when looking downwards with a high viewing distance but will be less useful with the default value. May have a minor to major performance impact. shadow map resolution diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 06950e50df..056ee4a1e1 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -805,8 +805,8 @@ enable debug hud = false # Enable the debug overlay to see where each shadow map affects. enable debug overlay = false -# Attempt to better use the shadow map by making them cover a smaller area. Especially helpful when looking downwards. May have a minor to major performance impact. -compute tight scene bounds = true +# Attempt to better use the shadow map by making them cover a smaller area. May have a minor to major performance impact. +compute tight scene bounds = false # How large to make the shadow map(s). Higher values increase GPU load, but can produce better-looking results. Power-of-two values may turn out to be faster on some GPU/driver combinations. shadow map resolution = 1024