tightscenebound is uncessary after water bbfix

pull/2812/head
bzzt 6 years ago committed by Bret Curtis
parent d42cb4f16d
commit dc33eeadf1

@ -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();
}

@ -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);
}

@ -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<SceneUtil::WorkQueue> mWorkQueue;
@ -560,6 +562,8 @@ namespace MWGui
void setMenuTransparency(float value);
void updatePinnedWindows();
void enableScene(bool enable);
};
}

@ -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<OpenThreads::Mutex> lock(mMutex);
if (mDone)
return;
mCondition.wait(&mMutex);
mMutex.unlock();
}
mutable OpenThreads::Condition mCondition;

@ -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();

@ -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<osg::Geometry> createWaterGeometry(float size, int segments, float textureRepeats)
{
osg::ref_ptr<osg::Vec3Array> 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;
}

@ -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

@ -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

Loading…
Cancel
Save