mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
fix: pass overrides
This commit is contained in:
parent
958c97f791
commit
aa44d88a2b
@ -115,8 +115,8 @@ std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, P
|
||||
ImageEffectUniquePtr ObjectParser::parseEffect (const JSON& it, Project& project) {
|
||||
const auto& passsOverrides = it.optional ("passes");
|
||||
return std::make_unique <ImageEffect> (ImageEffect {
|
||||
.id = it.require <int> ("id", "Image effect must have an id"),
|
||||
.name = it.require <std::string> ("name", "Image effect must have a name"),
|
||||
.id = it.optional <int> ("id", -1),
|
||||
.name = it.optional <std::string> ("name", "Effect without name"),
|
||||
.visible = it.user ("visible", project.properties, true),
|
||||
.passOverrides = passsOverrides.has_value () ? parseEffectPassOverrides (passsOverrides.value (), project) : std::vector <ImageEffectPassOverrideUniquePtr> {},
|
||||
.effect = EffectParser::load (project, it.require ("file", "Image effect must have an effect"))
|
||||
|
@ -59,7 +59,7 @@ CPass::CPass (
|
||||
m_blendingmode (pass.blending),
|
||||
m_binds (binds.has_value () ? binds.value ().get () : DEFAULT_BINDS),
|
||||
m_override (override.has_value () ? override.value ().get () : DEFAULT_OVERRIDE),
|
||||
m_fboProvider (fboProvider),
|
||||
m_fboProvider (std::move(fboProvider)),
|
||||
m_target (target) {
|
||||
this->setupShaders ();
|
||||
this->setupShaderVariables ();
|
||||
@ -502,16 +502,11 @@ void CPass::setupTextureUniforms () {
|
||||
// and then try with fragment's and override any existing
|
||||
for (const auto& [index, textureName] : this->m_shader->getVertex ().getTextures ()) {
|
||||
try {
|
||||
// resolve the texture first
|
||||
std::shared_ptr<const ITexture> textureRef;
|
||||
|
||||
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||
textureRef = this->resolveFBO (textureName);
|
||||
} else {
|
||||
textureRef = this->getContext ().resolveTexture (textureName);
|
||||
this->m_textures [index] = this->resolveFBO (textureName);
|
||||
} else if(!textureName.empty ()) {
|
||||
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||
}
|
||||
|
||||
this->m_textures [index] = textureRef;
|
||||
} catch (std::runtime_error& ex) {
|
||||
sLog.error ("Cannot resolve texture ", textureName, " for fragment shader ", ex.what ());
|
||||
}
|
||||
@ -519,16 +514,11 @@ void CPass::setupTextureUniforms () {
|
||||
|
||||
for (const auto& [index, textureName] : this->m_shader->getFragment ().getTextures ()) {
|
||||
try {
|
||||
// resolve the texture first
|
||||
std::shared_ptr<const ITexture> textureRef;
|
||||
|
||||
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||
textureRef = this->resolveFBO (textureName);
|
||||
} else {
|
||||
textureRef = this->getContext ().resolveTexture (textureName);
|
||||
this->m_textures [index] = this->resolveFBO (textureName);
|
||||
} else if(!textureName.empty ()) {
|
||||
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||
}
|
||||
|
||||
this->m_textures [index] = textureRef;
|
||||
} catch (std::runtime_error& ex) {
|
||||
sLog.error ("Cannot resolve texture ", textureName, " for fragment shader ", ex.what ());
|
||||
}
|
||||
@ -540,10 +530,31 @@ void CPass::setupTextureUniforms () {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (textureName.find ("_rt_") == 0) {
|
||||
this->m_textures[index] = this->resolveFBO (textureName);
|
||||
} else if (!textureName.empty ()) {
|
||||
this->m_textures[index] = this->m_image.getContext ().resolveTexture (textureName);
|
||||
try {
|
||||
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||
this->m_textures [index] = this->resolveFBO (textureName);
|
||||
} else if (!textureName.empty ()) {
|
||||
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||
}
|
||||
} catch (std::runtime_error& ex) {
|
||||
sLog.error ("Cannot resolve texture ", textureName, " for pass ", ex.what ());
|
||||
}
|
||||
}
|
||||
|
||||
// override any texture
|
||||
for (const auto& [index, textureName] : this->m_override.textures) {
|
||||
if (index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||
this->m_textures [index] = this->resolveFBO (textureName);
|
||||
} else if (!textureName.empty ()) {
|
||||
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||
}
|
||||
} catch (std::runtime_error& ex) {
|
||||
sLog.error ("Cannot resolve texture ", textureName, " for override ", ex.what ());
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,7 +563,7 @@ void CPass::setupTextureUniforms () {
|
||||
if (bind == "previous") {
|
||||
// use nullptr as indication for "previous" texture
|
||||
this->m_textures [index] = nullptr;
|
||||
} else {
|
||||
} else if(!bind.empty ()) {
|
||||
// a normal bind, search for the corresponding FBO and set it
|
||||
this->m_textures [index] = this->resolveFBO (bind);
|
||||
}
|
||||
|
@ -46,6 +46,14 @@ CScene::CScene (
|
||||
// setup framebuffers here as they're required for the scene setup
|
||||
this->setupFramebuffers ();
|
||||
|
||||
const uint32_t sceneWidth = this->m_camera->getWidth ();
|
||||
const uint32_t sceneHeight = this->m_camera->getHeight ();
|
||||
|
||||
this->_rt_shadowAtlas =
|
||||
this->create ("_rt_shadowAtlas", ITexture::TextureFormat::ARGB8888, ITexture::TextureFlags::ClampUVs, 1.0,
|
||||
{sceneWidth, sceneHeight}, {sceneWidth, sceneHeight});
|
||||
this->alias ("_alias_lightCookie", "_rt_shadowAtlas");
|
||||
|
||||
// set clear color
|
||||
// TODO: MAKE USE OF THE REFERENCE POSSIBILITIES?!
|
||||
const glm::vec3 clearColor = scene->colors.clear->value->getVec3 ();
|
||||
@ -67,9 +75,6 @@ CScene::CScene (
|
||||
this->m_objectsByRenderOrder.emplace_back (obj->second);
|
||||
}
|
||||
|
||||
const uint32_t sceneWidth = this->m_camera->getWidth ();
|
||||
const uint32_t sceneHeight = this->m_camera->getHeight ();
|
||||
|
||||
// create extra framebuffers for the bloom effect
|
||||
this->_rt_4FrameBuffer =
|
||||
this->create ("_rt_4FrameBuffer", ITexture::TextureFormat::ARGB8888, ITexture::TextureFlags::ClampUVs, 1.0,
|
||||
|
@ -52,5 +52,6 @@ class CScene final : public CWallpaper {
|
||||
std::shared_ptr<const CFBO> _rt_4FrameBuffer = nullptr;
|
||||
std::shared_ptr<const CFBO> _rt_8FrameBuffer = nullptr;
|
||||
std::shared_ptr<const CFBO> _rt_Bloom = nullptr;
|
||||
std::shared_ptr<const CFBO> _rt_shadowAtlas = nullptr;
|
||||
};
|
||||
} // namespace WallpaperEngine::Render::Wallpaper
|
||||
|
Loading…
Reference in New Issue
Block a user