diff --git a/crates/bevy_core_pipeline/src/auto_exposure/auto_exposure.wgsl b/crates/bevy_core_pipeline/src/auto_exposure/auto_exposure.wgsl index a4eca41477..6434b7e208 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/auto_exposure.wgsl +++ b/crates/bevy_core_pipeline/src/auto_exposure/auto_exposure.wgsl @@ -155,26 +155,26 @@ fn compute_average(@builtin(local_invocation_index) local_index: u32) { count += bin_count; } - var target_exposure = 0.0; + var avg_lum = settings.min_log_lum; if count > 0u { // The average luminance of the included histogram samples. - let avg_lum = sum / (f32(count) * 63.0) + avg_lum = sum / (f32(count) * 63.0) * settings.log_lum_range + settings.min_log_lum; - - // The position in the compensation curve texture to sample for avg_lum. - let u = (avg_lum - compensation_curve.min_log_lum) * compensation_curve.inv_log_lum_range; - - // The target exposure is the negative of the average log luminance. - // The compensation value is added to the target exposure to adjust the exposure for - // artistic purposes. - target_exposure = textureLoad(tex_compensation, i32(saturate(u) * 255.0), 0).r - * compensation_curve.compensation_range - + compensation_curve.min_compensation - - avg_lum; } + // The position in the compensation curve texture to sample for avg_lum. + let u = (avg_lum - compensation_curve.min_log_lum) * compensation_curve.inv_log_lum_range; + + // The target exposure is the negative of the average log luminance. + // The compensation value is added to the target exposure to adjust the exposure for + // artistic purposes. + let target_exposure = textureLoad(tex_compensation, i32(saturate(u) * 255.0), 0).r + * compensation_curve.compensation_range + + compensation_curve.min_compensation + - avg_lum; + // Smoothly adjust the `exposure` towards the `target_exposure` let delta = target_exposure - exposure; if target_exposure > exposure { diff --git a/examples/3d/auto_exposure.rs b/examples/3d/auto_exposure.rs index ff43dd66f6..44c64b84e8 100644 --- a/examples/3d/auto_exposure.rs +++ b/examples/3d/auto_exposure.rs @@ -111,7 +111,7 @@ fn setup( commands.spawn(PointLightBundle { point_light: PointLight { - intensity: 5000.0, + intensity: 2000.0, ..default() }, transform: Transform::from_xyz(0.0, 0.0, 0.0),