Fix: EEVEVE-Next: Wrong material reused for transmission material

This is caused by #121137 as the bug disappear if
`can_use_default_cb` returns false.


The issue is caused by the material binning system.
`ShaderKey` uses the `GPUMaterial` to differentiate between
material. But with #121137, different materials can reuse the
same `GPUMaterial`.

The fix is to not reuse the shader for the prepass (even if opaque)
for transmission enabled shaders.

Fix #121343
This commit is contained in:
Clément Foucault
2024-05-07 17:34:15 +02:00
parent a7eb1a13d4
commit 286cbc8317

View File

@@ -774,6 +774,8 @@ static bool can_use_default_cb(GPUMaterial *mat)
{
using namespace blender::gpu::shader;
const ::Material *blender_mat = GPU_material_get_material(mat);
uint64_t shader_uuid = GPU_material_uuid_get(mat);
eMaterialPipeline pipeline_type;
@@ -801,9 +803,11 @@ static bool can_use_default_cb(GPUMaterial *mat)
displacement_type != eMaterialDisplacement::MAT_DISPLACEMENT_BUMP;
bool has_transparency = GPU_material_flag_get(mat, GPU_MATFLAG_TRANSPARENT);
bool has_shadow_transparency = has_transparency && transparent_shadows;
bool has_raytraced_transmission = blender_mat && (blender_mat->blend_flag & MA_BL_SS_REFRACTION);
return (is_shadow_pass && (!has_vertex_displacement && !has_shadow_transparency)) ||
(is_prepass && (!has_vertex_displacement && !has_transparency));
(is_prepass &&
(!has_vertex_displacement && !has_transparency && !has_raytraced_transmission));
}
GPUMaterial *ShaderModule::material_default_shader_get(eMaterialPipeline pipeline_type,