Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions crates/bevy_post_process/src/bloom/bloom.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,11 @@ fn tonemapping_luminance(v: vec3<f32>) -> f32 {
return dot(v, vec3<f32>(0.2126, 0.7152, 0.0722));
}

fn rgb_to_srgb_simple(color: vec3<f32>) -> vec3<f32> {
return pow(color, vec3<f32>(1.0 / 2.2));
}

// http://graphicrants.blogspot.com/2013/12/tone-mapping.html
fn karis_average(color: vec3<f32>) -> f32 {
// Luminance calculated by gamma-correcting linear RGB to non-linear sRGB using pow(color, 1.0 / 2.2)
// and then calculating luminance based on Rec. 709 color primaries.
let luma = tonemapping_luminance(rgb_to_srgb_simple(color)) / 4.0;
// Luminance calculated based on Rec. 709 color primaries.
// This must be done in *linear* color space.
let luma = tonemapping_luminance(color) / 4.0;
return 1.0 / (1.0 + luma);
}

Expand Down
14 changes: 14 additions & 0 deletions release-content/migration-guides/bloom-luma-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Bloom luma calculation now in linear space"
pull_requests: [22561]
---

The luma calculation for bloom's Karis average (used for downsampling) has been corrected to use linear color space instead of non-linear sRGB space.

As a result, the intensity of the bloom effect may appear reduced, especially for colors with high saturation or those that were significantly affected by the previous non-linear calculation.

If your scene's bloom now appears too dim, you can:

- Increase the `intensity` field on the `Bloom` component.
- Increase the `emissive` strength of your materials.
- Adjust the `prefilter` settings in the `Bloom` component.