diff --git a/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp b/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp index c1b7a7f..8e5ba6c 100644 --- a/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp @@ -115,8 +115,8 @@ std::vector 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 { - .id = it.require ("id", "Image effect must have an id"), - .name = it.require ("name", "Image effect must have a name"), + .id = it.optional ("id", -1), + .name = it.optional ("name", "Effect without name"), .visible = it.user ("visible", project.properties, true), .passOverrides = passsOverrides.has_value () ? parseEffectPassOverrides (passsOverrides.value (), project) : std::vector {}, .effect = EffectParser::load (project, it.require ("file", "Image effect must have an effect")) diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp index dc604b3..841235d 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp @@ -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 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 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); } diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp index 6f1b58e..b8a3c60 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp @@ -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, diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.h b/src/WallpaperEngine/Render/Wallpapers/CScene.h index c43be96..5519bde 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.h +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.h @@ -52,5 +52,6 @@ class CScene final : public CWallpaper { std::shared_ptr _rt_4FrameBuffer = nullptr; std::shared_ptr _rt_8FrameBuffer = nullptr; std::shared_ptr _rt_Bloom = nullptr; + std::shared_ptr _rt_shadowAtlas = nullptr; }; } // namespace WallpaperEngine::Render::Wallpaper