From e5e00d92a5dd4a5d54481ba11488389af8c76e85 Mon Sep 17 00:00:00 2001 From: Zhenyuan Zhang Date: Thu, 23 Jun 2022 07:40:56 -0400 Subject: [PATCH] Separate pbr and tone mapping. --- crates/bevy_pbr/src/render/pbr.wgsl | 2 +- crates/bevy_pbr/src/render/pbr_functions.wgsl | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/bevy_pbr/src/render/pbr.wgsl b/crates/bevy_pbr/src/render/pbr.wgsl index 3f169d5104f66..f4ba112e6e555 100644 --- a/crates/bevy_pbr/src/render/pbr.wgsl +++ b/crates/bevy_pbr/src/render/pbr.wgsl @@ -85,7 +85,7 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4 { ); pbr_input.V = calculate_view(in.world_position, pbr_input.is_orthographic); - output_color = pbr(pbr_input); + output_color = tone_mapping(pbr(pbr_input)); } return output_color; diff --git a/crates/bevy_pbr/src/render/pbr_functions.wgsl b/crates/bevy_pbr/src/render/pbr_functions.wgsl index a2349fcbdeee3..04986fad1586e 100644 --- a/crates/bevy_pbr/src/render/pbr_functions.wgsl +++ b/crates/bevy_pbr/src/render/pbr_functions.wgsl @@ -186,11 +186,14 @@ fn pbr( cluster_index, ); + return output_color; +} + +fn tone_mapping(in: vec4) -> vec4 { // tone_mapping - output_color = vec4(reinhard_luminance(output_color.rgb), output_color.a); + return vec4(reinhard_luminance(in.rgb), in.a); + // Gamma correction. // Not needed with sRGB buffer // output_color.rgb = pow(output_color.rgb, vec3(1.0 / 2.2)); - - return output_color; }