diff --git a/crates/bevy_core_pipeline/src/tonemapping/tonemapping_shared.wgsl b/crates/bevy_core_pipeline/src/tonemapping/tonemapping_shared.wgsl index deafac0750d84..f538af1b2d812 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/tonemapping_shared.wgsl +++ b/crates/bevy_core_pipeline/src/tonemapping/tonemapping_shared.wgsl @@ -34,4 +34,4 @@ fn screen_space_dither(frag_coord: vec2) -> vec3 { var dither = vec3(dot(vec2(171.0, 231.0), frag_coord)).xxx; dither = fract(dither.rgb / vec3(103.0, 71.0, 97.0)); return (dither - 0.5) / 255.0; -} \ No newline at end of file +} diff --git a/crates/bevy_pbr/src/render/pbr.wgsl b/crates/bevy_pbr/src/render/pbr.wgsl index 6f5d94edfbaf3..cfe825190d2a5 100644 --- a/crates/bevy_pbr/src/render/pbr.wgsl +++ b/crates/bevy_pbr/src/render/pbr.wgsl @@ -99,7 +99,13 @@ fn fragment(in: FragmentInput) -> @location(0) vec4 { output_color = tone_mapping(output_color); #endif #ifdef DEBAND_DITHER - output_color = dither(output_color, in.frag_coord.xy); + var output_rgb = output_color.rgb; + output_rgb = pow(output_rgb, vec3(1.0 / 2.2)); + output_rgb = output_rgb + screen_space_dither(in.frag_coord.xy); + // This conversion back to linear space is required because our output texture format is + // SRGB; the GPU will assume our output is linear and will apply an SRGB conversion. + output_rgb = pow(output_rgb, vec3(2.2)); + output_color = vec4(output_rgb, output_color.a); #endif return output_color; }