From cf3774c48100cb5d2c56c8fef88cd31eeccf2e95 Mon Sep 17 00:00:00 2001 From: Almamu Date: Wed, 20 Aug 2025 01:12:28 +0200 Subject: [PATCH] chore: more fixes for visibility + camerashake can be a user setting --- src/WallpaperEngine/Data/Model/Wallpaper.h | 2 +- .../Data/Parsers/WallpaperParser.cpp | 2 +- src/WallpaperEngine/Render/Objects/CImage.cpp | 30 +++++++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/WallpaperEngine/Data/Model/Wallpaper.h b/src/WallpaperEngine/Data/Model/Wallpaper.h index 327fff5..ced5d13 100644 --- a/src/WallpaperEngine/Data/Model/Wallpaper.h +++ b/src/WallpaperEngine/Data/Model/Wallpaper.h @@ -80,7 +80,7 @@ struct SceneData { * Shake effect configuration */ struct { - bool enabled; + UserSettingUniquePtr enabled; float amplitude; float roughness; float speed; diff --git a/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp b/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp index e65b3aa..30ab449 100644 --- a/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp @@ -56,7 +56,7 @@ SceneUniquePtr WallpaperParser::parseScene (const JSON& file, Project& project) .mouseInfluence = general.optional ("cameraparallaxmouseinfluence", 1.0f), }, .shake = { - .enabled = general.optional ("camerashake", false), + .enabled = general.user ("camerashake", properties, false), .amplitude = general.optional ("camerashakeamplitude", 0.0f), .roughness = general.optional ("camerashakeroughness", 0.0f), .speed = general.optional ("camerashakespeed", 0.0f), diff --git a/src/WallpaperEngine/Render/Objects/CImage.cpp b/src/WallpaperEngine/Render/Objects/CImage.cpp index a04f7c1..3c39e64 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.cpp +++ b/src/WallpaperEngine/Render/Objects/CImage.cpp @@ -230,24 +230,38 @@ CImage::CImage (Wallpapers::CScene& scene, const Image& image) : void CImage::setup () { // do not double-init stuff, that's bad! - if (this->m_initialized) + if (this->m_initialized) { return; + } + + // TODO: SETUP RECALCULATION OF THINGS WHEN A VISIBILITY VALUE CHANGES!! + if (!this->m_image.visible->value->getBool ()) { + return; + } // TODO: SUPPORT PASSTHROUGH (IT'S A SHADER) // passthrough images without effects are bad, do not draw them - if (this->m_image.model->passthrough && this->m_image.effects.empty ()) + if (this->m_image.model->passthrough && this->m_image.effects.empty ()) { return; + } - // add blendmode to the combos - for (const auto& cur : this->getImage ().model->material->passes) + // copy pass to the composite layer + for (const auto& cur : this->getImage ().model->material->passes) { this->m_passes.push_back ( - new CPass (*this, std::make_shared(this), *cur, std::nullopt, std::nullopt, std::nullopt) + new CPass (*this, std::make_shared (this), *cur, std::nullopt, std::nullopt, std::nullopt) ); + } // prepare the passes list if (!this->getImage ().effects.empty ()) { // generate the effects used by this material for (const auto& cur : this->m_image.effects) { + // do not add non-visible effects, this might need some adjustements tho as some effects might not be visible + // but affect the output of the image... + if (!cur->visible->value->getBool ()) { + continue; + } + auto fboProvider = std::make_shared (this); // create all the fbos for this effect @@ -325,6 +339,7 @@ void CImage::setup () { } } + // extra render pass if there's any blending to be done if (this->m_image.colorBlendMode > 0) { this->m_materials.colorBlending.material = MaterialParser::load (this->getScene ().getScene ().project, "materials/util/effectpassthrough.json"); this->m_materials.colorBlending.override = std::make_unique (ImageEffectPassOverride { @@ -360,8 +375,9 @@ void CImage::setup () { // calculate full animation time (if any) this->m_animationTime = 0.0f; - for (const auto& cur : this->getTexture ()->getFrames ()) + for (const auto& cur : this->getTexture ()->getFrames ()) { this->m_animationTime += cur->frametime; + } this->setupPasses (); this->m_initialized = true; @@ -379,6 +395,8 @@ void CImage::setupPasses () { for (; cur != end; ++cur) { // TODO: PROPERLY CHECK EFFECT'S VISIBILITY AND TAKE IT INTO ACCOUNT + // TODO: THIS REQUIRES ON-THE-FLY EVALUATION OF EFFECTS VISIBILITY TO FIGURE OUT + // TODO: WHICH ONE IS THE LAST + A FEW OTHER THINGS Effects::CPass* pass = *cur; std::shared_ptr prevDrawTo = drawTo; GLuint spacePosition = (first) ? this->getCopySpacePosition () : this->getPassSpacePosition ();