From df69fc76597ac3c9cb6add9fea3e62d0dabc5a77 Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Sun, 7 Aug 2022 00:19:19 +0200 Subject: [PATCH] Post processing shaders now use the same lua commands, no more launcher option to enable live reload --- apps/launcher/advancedpage.cpp | 3 --- apps/openmw/mwlua/debugbindings.cpp | 10 ++++++++-- apps/openmw/mwrender/postprocessor.cpp | 12 ++++++++++-- apps/openmw/mwrender/postprocessor.hpp | 5 +++++ files/ui/advancedpage.ui | 13 ------------- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index ff04a846ff..17ac649dce 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -152,7 +152,6 @@ bool Launcher::AdvancedPage::loadSettings() connect(postprocessEnabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotPostProcessToggled(bool))); loadSettingBool(postprocessEnabledCheckBox, "enabled", "Post Processing"); - loadSettingBool(postprocessLiveReloadCheckBox, "live reload", "Post Processing"); loadSettingBool(postprocessTransparentPostpassCheckBox, "transparent postpass", "Post Processing"); postprocessHDRTimeComboBox->setValue(Settings::Manager::getDouble("auto exposure speed", "Post Processing")); @@ -309,7 +308,6 @@ void Launcher::AdvancedPage::saveSettings() saveSettingBool(nightDaySwitchesCheckBox, "day night switches", "Game"); saveSettingBool(postprocessEnabledCheckBox, "enabled", "Post Processing"); - saveSettingBool(postprocessLiveReloadCheckBox, "live reload", "Post Processing"); saveSettingBool(postprocessTransparentPostpassCheckBox, "transparent postpass", "Post Processing"); double hdrExposureTime = postprocessHDRTimeComboBox->value(); if (hdrExposureTime != Settings::Manager::getDouble("auto exposure speed", "Post Processing")) @@ -466,7 +464,6 @@ void Launcher::AdvancedPage::slotAnimSourcesToggled(bool checked) void Launcher::AdvancedPage::slotPostProcessToggled(bool checked) { - postprocessLiveReloadCheckBox->setEnabled(checked); postprocessTransparentPostpassCheckBox->setEnabled(checked); postprocessHDRTimeComboBox->setEnabled(checked); postprocessHDRTimeLabel->setEnabled(checked); diff --git a/apps/openmw/mwlua/debugbindings.cpp b/apps/openmw/mwlua/debugbindings.cpp index d8a257a032..d51ab1897b 100644 --- a/apps/openmw/mwlua/debugbindings.cpp +++ b/apps/openmw/mwlua/debugbindings.cpp @@ -5,6 +5,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwrender/renderingmanager.hpp" +#include "../mwrender/postprocessor.hpp" #include #include @@ -54,7 +55,10 @@ namespace MWLua { context.mLuaManager->addAction([] { - MWBase::Environment::get().getWorld()->getRenderingManager()->getResourceSystem()->getSceneManager()->getShaderManager().triggerShaderReload(); + auto world = MWBase::Environment::get().getWorld(); + + world->getRenderingManager()->getResourceSystem()->getSceneManager()->getShaderManager().triggerShaderReload(); + world->getPostProcessor()->triggerShaderReload(); }); }; @@ -62,7 +66,9 @@ namespace MWLua { context.mLuaManager->addAction([value] { - MWBase::Environment::get().getWorld()->getRenderingManager()->getResourceSystem()->getSceneManager()->getShaderManager().setHotReloadEnabled(value); + auto world = MWBase::Environment::get().getWorld(); + world->getRenderingManager()->getResourceSystem()->getSceneManager()->getShaderManager().setHotReloadEnabled(value); + world->getPostProcessor()->mEnableLiveReload = value; }); }; diff --git a/apps/openmw/mwrender/postprocessor.cpp b/apps/openmw/mwrender/postprocessor.cpp index 4902dc8ef8..1946efb145 100644 --- a/apps/openmw/mwrender/postprocessor.cpp +++ b/apps/openmw/mwrender/postprocessor.cpp @@ -102,6 +102,7 @@ namespace MWRender { PostProcessor::PostProcessor(RenderingManager& rendering, osgViewer::Viewer* viewer, osg::Group* rootNode, const VFS::Manager* vfs) : osg::Group() + , mEnableLiveReload(false) , mRootNode(rootNode) , mSamples(Settings::Manager::getInt("antialiasing", "Video")) , mDirty(false) @@ -109,6 +110,7 @@ namespace MWRender , mRendering(rendering) , mViewer(viewer) , mVFS(vfs) + , mTriggerShaderReload(false) , mReload(false) , mEnabled(false) , mUsePostProcessing(false) @@ -370,10 +372,11 @@ namespace MWRender void PostProcessor::updateLiveReload() { - static const bool liveReload = Settings::Manager::getBool("live reload", "Post Processing"); - if (!liveReload) + if (!mEnableLiveReload && !mTriggerShaderReload) return; + mTriggerShaderReload = false;//Done only once + for (auto& technique : mTechniques) { if (technique->getStatus() == fx::Technique::Status::File_Not_exists) @@ -890,5 +893,10 @@ namespace MWRender return Stereo::Manager::instance().eyeResolution().y(); return mHeight; } + + void PostProcessor::triggerShaderReload() + { + mTriggerShaderReload = true; + } } diff --git a/apps/openmw/mwrender/postprocessor.hpp b/apps/openmw/mwrender/postprocessor.hpp index 2fa3e5622a..fc20340a29 100644 --- a/apps/openmw/mwrender/postprocessor.hpp +++ b/apps/openmw/mwrender/postprocessor.hpp @@ -180,6 +180,10 @@ namespace MWRender int renderWidth() const; int renderHeight() const; + void triggerShaderReload(); + + bool mEnableLiveReload; + private: void populateTechniqueFiles(); @@ -225,6 +229,7 @@ namespace MWRender osgViewer::Viewer* mViewer; const VFS::Manager* mVFS; + bool mTriggerShaderReload; bool mReload; bool mEnabled; bool mUsePostProcessing; diff --git a/files/ui/advancedpage.ui b/files/ui/advancedpage.ui index bcf710ffea..82add7b6b6 100644 --- a/files/ui/advancedpage.ui +++ b/files/ui/advancedpage.ui @@ -670,19 +670,6 @@ 20 - - - - false - - - <html><head/><body><p>Debug Mode. Automatically reload active shaders when they are modified on filesystem.</p></body></html> - - - Live reload - - -