From 4b78ba01628a6cee938f016e0c5eb71b3584df0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Tiselice?= Date: Mon, 9 Sep 2024 17:14:50 +0200 Subject: [PATCH] Replaced implicit emissive weight with default. (#13871) Since `StandardMaterial::emissive_exposure_weight` does not get packed into the gbuffer in the deferred case, unpacking uses an implicit default value for emissive's alpha channel. This resulted in divergent behavior between the forward and deferred renderers when using standard materials with default emissive_exposure_weight, this value defaulting to `0.0` in the forward case and `1.0` in the other. This patch changes the implicit value in the deferred case to `0.0` in order to match the behavior of the forward renderer. However, this still does not solve the case where `emissive_exposure_weight` is not `0.0`. --- crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl b/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl index f317f15b5ab7b..b892181377a99 100644 --- a/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl +++ b/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl @@ -76,10 +76,10 @@ fn pbr_input_from_deferred_gbuffer(frag_coord: vec4, gbuffer: vec4) -> let emissive = rgb9e5::rgb9e5_to_vec3_(gbuffer.g); if ((pbr.material.flags & STANDARD_MATERIAL_FLAGS_UNLIT_BIT) != 0u) { pbr.material.base_color = vec4(emissive, 1.0); - pbr.material.emissive = vec4(vec3(0.0), 1.0); + pbr.material.emissive = vec4(vec3(0.0), 0.0); } else { pbr.material.base_color = vec4(pow(base_rough.rgb, vec3(2.2)), 1.0); - pbr.material.emissive = vec4(emissive, 1.0); + pbr.material.emissive = vec4(emissive, 0.0); } #ifdef WEBGL2 // More crunched for webgl so we can also fit depth. let props = deferred_types::unpack_unorm3x4_plus_unorm_20_(gbuffer.b);