1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Merge branch 'make_way_for_street_sweeper' into 'master'

[Postprocessing] Small cleanup

See merge request OpenMW/openmw!2037
This commit is contained in:
psi29a 2022-06-20 06:58:40 +00:00
commit a768068db9
2 changed files with 16 additions and 22 deletions

View File

@ -228,22 +228,11 @@ namespace MWRender
mViewer->setSceneData(this); mViewer->setSceneData(this);
mViewer->getCamera()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); mViewer->getCamera()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
mViewer->getCamera()->setImplicitBufferAttachmentMask(0, 0);
mViewer->getCamera()->getGraphicsContext()->setResizedCallback(new ResizedCallback(this)); mViewer->getCamera()->getGraphicsContext()->setResizedCallback(new ResizedCallback(this));
mViewer->getCamera()->setUserData(this); mViewer->getCamera()->setUserData(this);
setCullCallback(mStateUpdater); setCullCallback(mStateUpdater);
mHUDCamera->setCullCallback(new HUDCullCallback); mHUDCamera->setCullCallback(new HUDCullCallback);
static bool init = false;
if (init)
{
resize();
init = true;
}
init = true;
} }
void PostProcessor::disable() void PostProcessor::disable()
@ -631,7 +620,7 @@ namespace MWRender
auto it = technique->getRenderTargetsMap().find(whitelist); auto it = technique->getRenderTargetsMap().find(whitelist);
if (it != technique->getRenderTargetsMap().end() && renderTargetCache[it->second.mTarget]) if (it != technique->getRenderTargetsMap().end() && renderTargetCache[it->second.mTarget])
{ {
subPass.mStateSet->setTextureAttributeAndModes(subTexUnit, renderTargetCache[it->second.mTarget]); subPass.mStateSet->setTextureAttribute(subTexUnit, renderTargetCache[it->second.mTarget]);
subPass.mStateSet->addUniform(new osg::Uniform(std::string(it->first).c_str(), subTexUnit++)); subPass.mStateSet->addUniform(new osg::Uniform(std::string(it->first).c_str(), subTexUnit++));
} }
} }
@ -660,7 +649,7 @@ namespace MWRender
return Status_Error; return Status_Error;
} }
if (!technique || Misc::StringUtils::ciEqual(technique->getName(), "main") || (location.has_value() && location.value() <= 0)) if (!technique || technique->getLocked() || (location.has_value() && location.value() <= 0))
return Status_Error; return Status_Error;
disableTechnique(technique, false); disableTechnique(technique, false);
@ -675,7 +664,7 @@ namespace MWRender
PostProcessor::Status PostProcessor::disableTechnique(std::shared_ptr<fx::Technique> technique, bool dirty) PostProcessor::Status PostProcessor::disableTechnique(std::shared_ptr<fx::Technique> technique, bool dirty)
{ {
if (Misc::StringUtils::ciEqual(technique->getName(), "main")) if (technique->getLocked())
return Status_Error; return Status_Error;
auto it = std::find(mTechniques.begin(), mTechniques.end(), technique); auto it = std::find(mTechniques.begin(), mTechniques.end(), technique);
@ -819,21 +808,22 @@ namespace MWRender
std::vector<std::string> techniqueStrings; std::vector<std::string> techniqueStrings;
Misc::StringUtils::split(Settings::Manager::getString("chain", "Post Processing"), techniqueStrings, ","); Misc::StringUtils::split(Settings::Manager::getString("chain", "Post Processing"), techniqueStrings, ",");
techniqueStrings.insert(techniqueStrings.begin(), "main"); const std::string& mainIdentifier = "main";
auto main = loadTechnique(mainIdentifier);
if (main)
main->setLocked(true);
mTechniques.push_back(std::move(main));
for (auto& techniqueName : techniqueStrings) for (auto& techniqueName : techniqueStrings)
{ {
Misc::StringUtils::trim(techniqueName); Misc::StringUtils::trim(techniqueName);
if (techniqueName.empty()) if (techniqueName.empty() || Misc::StringUtils::ciEqual(techniqueName, mainIdentifier))
continue; continue;
if ((&techniqueName != &techniqueStrings.front()) && techniqueName == "main")
{
Log(Debug::Warning) << "main.omwfx techniqued specified in chain, this is not allowed. technique file will be ignored if it exists.";
continue;
}
mTechniques.push_back(loadTechnique(techniqueName)); mTechniques.push_back(loadTechnique(techniqueName));
} }

View File

@ -175,6 +175,9 @@ namespace fx
bool getDynamic() const { return mDynamic; } bool getDynamic() const { return mDynamic; }
void setLocked(bool locked) { mLocked = locked; }
bool getLocked() const { return mLocked; }
private: private:
[[noreturn]] void error(const std::string& msg); [[noreturn]] void error(const std::string& msg);
@ -293,6 +296,7 @@ namespace fx
std::string mLastError; std::string mLastError;
bool mDynamic = false; bool mDynamic = false;
bool mLocked = false;
}; };
template<> void Technique::parseBlockImp<Lexer::Shared>(); template<> void Technique::parseBlockImp<Lexer::Shared>();