diff --git a/src/WallpaperEngine/Data/Parsers/EffectParser.cpp b/src/WallpaperEngine/Data/Parsers/EffectParser.cpp index d2e63b3..98709d0 100644 --- a/src/WallpaperEngine/Data/Parsers/EffectParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/EffectParser.cpp @@ -51,7 +51,7 @@ std::vector EffectParser::parseEffectPasses (const JSON& i } for (const auto& cur : it) { - const auto binds = cur.optional ("binds"); + const auto binds = cur.optional ("bind"); std::optional command = std::nullopt; if (cur.contains ("command")) { diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp index 841235d..ac6c254 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp @@ -426,7 +426,7 @@ void CPass::setupShaders () { // use the combos copied from the pass so it includes the texture format this->m_shader = new Render::Shaders::CShader ( this->m_image.getContainer (), this->m_pass.shader, this->m_combos, - this->m_pass.textures, this->m_override.constants + this->m_pass.textures, this->m_override.textures, this->m_override.constants ); const auto shaders = Shaders::CGLSLContext::get ().toGlsl ( diff --git a/src/WallpaperEngine/Render/Shaders/CShader.cpp b/src/WallpaperEngine/Render/Shaders/CShader.cpp index 44ad97d..d2413ed 100644 --- a/src/WallpaperEngine/Render/Shaders/CShader.cpp +++ b/src/WallpaperEngine/Render/Shaders/CShader.cpp @@ -20,17 +20,19 @@ namespace WallpaperEngine::Render::Shaders { CShader::CShader ( const CContainer& container, std::string filename, const ComboMap& combos, const TextureMap& textures, + const TextureMap& overrideTextures, const ShaderConstantMap& constants ) : m_file (std::move (filename)), m_combos (combos), m_passTextures (textures), + m_overrideTextures (overrideTextures), m_vertex ( CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename), - container, constants, textures, combos), + container, constants, textures, overrideTextures, combos), m_fragment ( CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename), - container, constants, textures, combos) { + container, constants, textures, overrideTextures, combos) { // link shaders between them this->m_vertex.linkToUnit (&this->m_fragment); this->m_fragment.linkToUnit (&this->m_vertex); diff --git a/src/WallpaperEngine/Render/Shaders/CShader.h b/src/WallpaperEngine/Render/Shaders/CShader.h index 4ca3445..0638f9b 100644 --- a/src/WallpaperEngine/Render/Shaders/CShader.h +++ b/src/WallpaperEngine/Render/Shaders/CShader.h @@ -47,6 +47,7 @@ class CShader { CShader ( const CContainer& container, std::string filename, const ComboMap& combos, const TextureMap& textures, + const TextureMap& overrideTextures, const ShaderConstantMap& constants); /** * @return The vertex's shader coude for OpenGL to use @@ -101,5 +102,9 @@ class CShader { * The list of textures the pass knows about */ const TextureMap m_passTextures; + /** + * The list of the override textures + */ + const TextureMap& m_overrideTextures; }; } // namespace WallpaperEngine::Render::Shaders diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp index 8c49614..4c00202 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp +++ b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp @@ -57,7 +57,8 @@ using namespace WallpaperEngine::Render::Shaders; CShaderUnit::CShaderUnit ( CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container, - const ShaderConstantMap& constants, const TextureMap& passTextures, const ComboMap& combos + const ShaderConstantMap& constants, const TextureMap& passTextures, const TextureMap& overrideTextures, + const ComboMap& combos ) : m_type (type), m_link (nullptr), @@ -66,6 +67,7 @@ CShaderUnit::CShaderUnit ( m_constants (constants), m_content (std::move(content)), m_passTextures (passTextures), + m_overrideTextures (overrideTextures), m_combos (combos), m_discoveredCombos (), m_usedCombos () { @@ -409,15 +411,17 @@ void CShaderUnit::parseParameterConfiguration ( const auto requireany = data.find ("requireany"); const auto require = data.find ("require"); // now convert it to integer + // TODO: BETTER CONVERSION HERE size_t index = value - '0'; if (combo != data.end ()) { + // TODO: CLEANUP HOW THIS IS DETERMINED FIRST // if the texture exists (and is not null), add to the combo - auto texture = this->m_passTextures.find (index); + auto textureSlotUsed = this->m_passTextures.find (index) != this->m_passTextures.end () || this->m_overrideTextures.find (index) != this->m_overrideTextures.end (); bool isRequired = false; int comboValue = 1; - if (texture != this->m_passTextures.end ()) { + if (textureSlotUsed) { // nothing extra to do, the texture exists, the combo must be set // these tend to not have default value isRequired = true; @@ -452,7 +456,7 @@ void CShaderUnit::parseParameterConfiguration ( } } - if (isRequired && texture == this->m_passTextures.end ()) { + if (isRequired && !textureSlotUsed) { if (defvalue == data.end ()) { isRequired = false; } else { diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.h b/src/WallpaperEngine/Render/Shaders/CShaderUnit.h index 97f6713..df365a3 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.h +++ b/src/WallpaperEngine/Render/Shaders/CShaderUnit.h @@ -27,7 +27,7 @@ class CShaderUnit { CShaderUnit ( CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container, const ShaderConstantMap& constants, const TextureMap& passTextures, - const ComboMap& combos); + const TextureMap& overrideTextures, const ComboMap& combos); ~CShaderUnit () = default; /** @@ -145,7 +145,9 @@ class CShaderUnit { */ const ShaderConstantMap& m_constants; /** The textures that are already applied to this shader */ - const TextureMap m_passTextures = {}; + const TextureMap& m_passTextures; + /** The textures that are being overridden */ + const TextureMap& m_overrideTextures; /** The default textures to use when a texture is not applied in a given slot */ TextureMap m_defaultTextures = {}; /**