chore: more fixes for visibility + camerashake can be a user setting

This commit is contained in:
Almamu 2025-08-20 01:12:28 +02:00
parent ce51cd23fa
commit cf3774c481
3 changed files with 26 additions and 8 deletions

View File

@ -80,7 +80,7 @@ struct SceneData {
* Shake effect configuration * Shake effect configuration
*/ */
struct { struct {
bool enabled; UserSettingUniquePtr enabled;
float amplitude; float amplitude;
float roughness; float roughness;
float speed; float speed;

View File

@ -56,7 +56,7 @@ SceneUniquePtr WallpaperParser::parseScene (const JSON& file, Project& project)
.mouseInfluence = general.optional ("cameraparallaxmouseinfluence", 1.0f), .mouseInfluence = general.optional ("cameraparallaxmouseinfluence", 1.0f),
}, },
.shake = { .shake = {
.enabled = general.optional ("camerashake", false), .enabled = general.user ("camerashake", properties, false),
.amplitude = general.optional ("camerashakeamplitude", 0.0f), .amplitude = general.optional ("camerashakeamplitude", 0.0f),
.roughness = general.optional ("camerashakeroughness", 0.0f), .roughness = general.optional ("camerashakeroughness", 0.0f),
.speed = general.optional ("camerashakespeed", 0.0f), .speed = general.optional ("camerashakespeed", 0.0f),

View File

@ -230,24 +230,38 @@ CImage::CImage (Wallpapers::CScene& scene, const Image& image) :
void CImage::setup () { void CImage::setup () {
// do not double-init stuff, that's bad! // do not double-init stuff, that's bad!
if (this->m_initialized) if (this->m_initialized) {
return; 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) // TODO: SUPPORT PASSTHROUGH (IT'S A SHADER)
// passthrough images without effects are bad, do not draw them // 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; return;
}
// add blendmode to the combos // copy pass to the composite layer
for (const auto& cur : this->getImage ().model->material->passes) for (const auto& cur : this->getImage ().model->material->passes) {
this->m_passes.push_back ( this->m_passes.push_back (
new CPass (*this, std::make_shared<CFBOProvider> (this), *cur, std::nullopt, std::nullopt, std::nullopt) new CPass (*this, std::make_shared<CFBOProvider> (this), *cur, std::nullopt, std::nullopt, std::nullopt)
); );
}
// prepare the passes list // prepare the passes list
if (!this->getImage ().effects.empty ()) { if (!this->getImage ().effects.empty ()) {
// generate the effects used by this material // generate the effects used by this material
for (const auto& cur : this->m_image.effects) { 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<CFBOProvider> (this); auto fboProvider = std::make_shared<CFBOProvider> (this);
// create all the fbos for this effect // 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) { 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.material = MaterialParser::load (this->getScene ().getScene ().project, "materials/util/effectpassthrough.json");
this->m_materials.colorBlending.override = std::make_unique<ImageEffectPassOverride> (ImageEffectPassOverride { this->m_materials.colorBlending.override = std::make_unique<ImageEffectPassOverride> (ImageEffectPassOverride {
@ -360,8 +375,9 @@ void CImage::setup () {
// calculate full animation time (if any) // calculate full animation time (if any)
this->m_animationTime = 0.0f; 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->m_animationTime += cur->frametime;
}
this->setupPasses (); this->setupPasses ();
this->m_initialized = true; this->m_initialized = true;
@ -379,6 +395,8 @@ void CImage::setupPasses () {
for (; cur != end; ++cur) { for (; cur != end; ++cur) {
// TODO: PROPERLY CHECK EFFECT'S VISIBILITY AND TAKE IT INTO ACCOUNT // 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; Effects::CPass* pass = *cur;
std::shared_ptr<const CFBO> prevDrawTo = drawTo; std::shared_ptr<const CFBO> prevDrawTo = drawTo;
GLuint spacePosition = (first) ? this->getCopySpacePosition () : this->getPassSpacePosition (); GLuint spacePosition = (first) ? this->getCopySpacePosition () : this->getPassSpacePosition ();