From 181dd1eef85e6a6bff3acfc9dd0ad1e22c85236f Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Sun, 7 May 2023 18:54:01 +0200 Subject: [PATCH] Fix for #161, texture priorities were not being properly taken into account Signed-off-by: Alexis Maiquez --- src/WallpaperEngine/Core/Objects/CEffect.cpp | 2 +- src/WallpaperEngine/Render/Objects/Effects/CPass.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/WallpaperEngine/Core/Objects/CEffect.cpp b/src/WallpaperEngine/Core/Objects/CEffect.cpp index 9835091..5ad29be 100644 --- a/src/WallpaperEngine/Core/Objects/CEffect.cpp +++ b/src/WallpaperEngine/Core/Objects/CEffect.cpp @@ -110,7 +110,7 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, CObject* ob texture = texturesCur; } - std::vector passTextures = passCur->getTextures (); + const auto& passTextures = passCur->getTextures (); if (textureNumber < passTextures.size ()) passCur->setTexture (textureNumber, texture); diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp index 25c47d9..d987d5d 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp @@ -511,14 +511,14 @@ void CPass::setupUniforms () { if (bindCur != bindEnd) { - this->m_finalTextures.insert (std::make_pair ((*bindCur).first, nullptr)); + this->m_finalTextures [(*bindCur).first] = nullptr; bindCur ++; } if (cur != end) { if ((*cur) != nullptr) - this->m_finalTextures.insert (std::make_pair (index, *cur)); + this->m_finalTextures [index] = *cur; index ++; cur ++; @@ -543,7 +543,9 @@ void CPass::setupUniforms () else textureRef = this->getContext ().resolveTexture (textureName); - this->m_finalTextures.insert (std::make_pair ((*fragCur).first, textureRef)); + // ensure there's no texture in that slot already, shader textures are defaults in case nothing is there + if (this->m_finalTextures.find ((*fragCur).first) == this->m_finalTextures.end ()) + this->m_finalTextures [(*fragCur).first] = textureRef; } catch (std::runtime_error& ex) { @@ -572,7 +574,9 @@ void CPass::setupUniforms () else textureRef = this->getContext ().resolveTexture (textureName); - this->m_finalTextures.insert (std::make_pair ((*vertCur).first, textureRef)); + // ensure there's no texture in that slot already, shader textures are defaults in case nothing is there + if (this->m_finalTextures.find ((*vertCur).first) == this->m_finalTextures.end ()) + this->m_finalTextures [(*vertCur).first] = textureRef; } catch (std::runtime_error& ex) {