Skip to content

Commit

Permalink
fix shadow multiplier mode
Browse files Browse the repository at this point in the history
when shadow multiplier was used, the material used the wrong
variant (unlit).
  • Loading branch information
pixelflinger authored and poweifeng committed Oct 14, 2024
1 parent 9bd994e commit b8f43e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion libs/filamat/src/GLSLPostProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion libs/filamat/src/MaterialBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MaterialDescriptorBindingsChuck>(info.sib, perViewDescriptorSetLayout);
Expand Down
6 changes: 4 additions & 2 deletions libs/filamat/src/MaterialVariants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ std::vector<Variant> 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) {
Expand Down
3 changes: 2 additions & 1 deletion libs/filamat/src/shaders/ShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit b8f43e4

Please sign in to comment.