From 0d4c76c9862508e092b007ea6be5be129d20107a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 23 Aug 2024 16:44:54 +0200 Subject: [PATCH] Fix: EEVEE: Material without Closure flag skip rendering If a deferred layer doesn't contain any material with a non-null closure flag, the deferred layer is skipped. However, material with null closure flag exists and still need to render opaque. Fix this case by modifying the closure bits for the deferred and probe pipelines. Candidate for backporting to 4.2 Fix #126459 --- .../draw/engines/eevee_next/eevee_pipeline.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 36539e1fbca..2789475c920 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -750,6 +750,12 @@ PassMain::Sub *DeferredLayer::prepass_add(::Material *blender_mat, PassMain::Sub *DeferredLayer::material_add(::Material *blender_mat, GPUMaterial *gpumat) { eClosureBits closure_bits = shader_closure_bits_from_flag(gpumat); + if (closure_bits == eClosureBits(0)) { + /* Fix the case where there is no active closure in the shader. + * In this case we force the evaluation of emission to avoid disabling the entire layer by + * accident, see #126459. */ + closure_bits |= CLOSURE_EMISSION; + } closure_bits_ |= closure_bits; closure_count_ = max_ii(closure_count_, count_bits_i(closure_bits)); @@ -1269,6 +1275,12 @@ PassMain::Sub *DeferredProbePipeline::prepass_add(::Material *blender_mat, GPUMa PassMain::Sub *DeferredProbePipeline::material_add(::Material *blender_mat, GPUMaterial *gpumat) { eClosureBits closure_bits = shader_closure_bits_from_flag(gpumat); + if (closure_bits == eClosureBits(0)) { + /* Fix the case where there is no active closure in the shader. + * In this case we force the evaluation of emission to avoid disabling the entire layer by + * accident, see #126459. */ + closure_bits |= CLOSURE_EMISSION; + } opaque_layer_.closure_bits_ |= closure_bits; opaque_layer_.closure_count_ = max_ii(opaque_layer_.closure_count_, count_bits_i(closure_bits)); @@ -1380,6 +1392,12 @@ PassMain::Sub *PlanarProbePipeline::prepass_add(::Material *blender_mat, GPUMate PassMain::Sub *PlanarProbePipeline::material_add(::Material *blender_mat, GPUMaterial *gpumat) { eClosureBits closure_bits = shader_closure_bits_from_flag(gpumat); + if (closure_bits == eClosureBits(0)) { + /* Fix the case where there is no active closure in the shader. + * In this case we force the evaluation of emission to avoid disabling the entire layer by + * accident, see #126459. */ + closure_bits |= CLOSURE_EMISSION; + } closure_bits_ |= closure_bits; closure_count_ = max_ii(closure_count_, count_bits_i(closure_bits));