From 1c365423d94bdcdde9449f8e1d782a34005d56ea Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 4 Oct 2024 14:15:06 -0700 Subject: [PATCH] fix shadow multiplier mode when shadow multiplier was used, the material used the wrong variant (unlit). --- libs/filamat/src/GLSLPostProcessor.cpp | 4 +++- libs/filamat/src/MaterialBuilder.cpp | 2 +- libs/filamat/src/MaterialVariants.cpp | 6 ++++-- libs/filamat/src/shaders/ShaderGenerator.cpp | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/filamat/src/GLSLPostProcessor.cpp b/libs/filamat/src/GLSLPostProcessor.cpp index 9cb9ae6b4bf..9dc98b00d3b 100644 --- a/libs/filamat/src/GLSLPostProcessor.cpp +++ b/libs/filamat/src/GLSLPostProcessor.cpp @@ -157,7 +157,9 @@ static void collectDescriptorsForSet(filament::DescriptorSetBindingPoints set, return descriptor_sets::getSsrVariantLayout(); } return descriptor_sets::getPerViewDescriptorSetLayout(config.domain, - config.variantFilter, material.isLit, material.reflectionMode, + config.variantFilter, + material.isLit || material.hasShadowMultiplier, + material.reflectionMode, material.refractionMode); } case DescriptorSetBindingPoints::PER_RENDERABLE: diff --git a/libs/filamat/src/MaterialBuilder.cpp b/libs/filamat/src/MaterialBuilder.cpp index 816671aae5c..96563bfa6e1 100644 --- a/libs/filamat/src/MaterialBuilder.cpp +++ b/libs/filamat/src/MaterialBuilder.cpp @@ -1551,7 +1551,7 @@ void MaterialBuilder::writeCommonChunks(ChunkContainer& container, MaterialInfo& backend::DescriptorSetLayout const perViewDescriptorSetLayout = descriptor_sets::getPerViewDescriptorSetLayout( mMaterialDomain, mVariantFilter, - info.isLit, info.reflectionMode, info.refractionMode); + info.isLit || info.hasShadowMultiplier, info.reflectionMode, info.refractionMode); // Descriptor layout and descriptor name/binding mapping container.push(info.sib, perViewDescriptorSetLayout); diff --git a/libs/filamat/src/MaterialVariants.cpp b/libs/filamat/src/MaterialVariants.cpp index 06a70d60fc8..b6ce7ccd745 100644 --- a/libs/filamat/src/MaterialVariants.cpp +++ b/libs/filamat/src/MaterialVariants.cpp @@ -86,9 +86,11 @@ std::vector determineSurfaceVariants( RefractionMode::CUBEMAP, RefractionMode::NONE }) { auto const vdsl = ShaderGenerator::getPerViewDescriptorSetLayoutWithVariant( - vertexVariant, userVariantFilter, isLit, reflection, refraction); + vertexVariant, userVariantFilter, isLit || shadowMultiplier, + reflection, refraction); auto const fdsl = ShaderGenerator::getPerViewDescriptorSetLayoutWithVariant( - fragmentVariant, userVariantFilter, isLit, reflection, refraction); + fragmentVariant, userVariantFilter, isLit || shadowMultiplier, + reflection, refraction); // Check that all bindings present in the vertex shader DescriptorSetLayout // are also present in the fragment shader DescriptorSetLayout. for (auto const& r: vdsl.bindings) { diff --git a/libs/filamat/src/shaders/ShaderGenerator.cpp b/libs/filamat/src/shaders/ShaderGenerator.cpp index ff9486ad193..45b78cc0439 100644 --- a/libs/filamat/src/shaders/ShaderGenerator.cpp +++ b/libs/filamat/src/shaders/ShaderGenerator.cpp @@ -608,7 +608,8 @@ std::string ShaderGenerator::createFragmentProgram(ShaderModel shaderModel, auto const perViewDescriptorSetLayout = getPerViewDescriptorSetLayoutWithVariant( variant, variantFilter, - material.isLit, material.reflectionMode, material.refractionMode); + material.isLit || material.hasShadowMultiplier, + material.reflectionMode, material.refractionMode); // this is the list of samplers we need to filter auto list = SibGenerator::getPerViewSib(variant).getSamplerInfoList();