mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
Set the default target exposure to the minimum value, not 0 (#13562)
# Objective - In particularly dark scenes, auto-exposure would lead to an unexpected darkening of the view. - Fixes #13446. ## Solution The average luminance should default to something else than 0.0 instead, when there are no samples. We set it to `settings.min_log_lum`. ## Testing I was able to reproduce the problem on the `auto_exposure` example by setting the point light intensity to 2000 and looking into the right-hand corner. There was a sudden darkening. Now, the discontinuity is gone. --------- Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com> Co-authored-by: Bram Buurlage <brambuurlage@gmail.com>
This commit is contained in:
parent
4e72bf4751
commit
9d74e16821
2 changed files with 14 additions and 14 deletions
|
@ -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 {
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Reference in a new issue