Skip to content

Commit ea0c52c

Browse files
committed
Add Bloom.max_mip_count
1 parent bcaec79 commit ea0c52c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

crates/bevy_post_process/src/bloom/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,12 @@ fn prepare_bloom_textures(
361361
for (entity, camera, bloom) in &views {
362362
if let Some(viewport) = camera.physical_viewport_size {
363363
// How many times we can halve the resolution minus one so we don't go unnecessarily low
364-
let mip_count = bloom.max_mip_dimension.ilog2().max(2) - 1;
364+
let mip_count = bloom
365+
.max_mip_dimension
366+
.ilog2()
367+
.min(bloom.max_mip_count)
368+
.max(2)
369+
- 1;
365370
let mip_dim_ratio = if viewport.y != 0 && viewport.x != 0 {
366371
(bloom.max_mip_dimension as f32 / viewport.as_vec2()).max_element()
367372
} else {

crates/bevy_post_process/src/bloom/settings.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ pub struct Bloom {
116116
pub composite_mode: BloomCompositeMode,
117117

118118
/// Maximum size of each dimension for the largest mipchain texture used in downscaling/upscaling.
119-
/// Lower values can improve performance but reduce quality.
119+
/// Lower values can improve performance but result in more aliasing.
120120
pub max_mip_dimension: u32,
121121

122+
/// Maximum number of mipmaps to use in downscaling/upscaling (default: [`u32::MAX`]).
123+
/// Lower values can improve performance but lose some low frequency contributions.
124+
pub max_mip_count: u32,
125+
122126
/// Amount to stretch the bloom on each axis. Artistic control, can be used to emulate
123127
/// anamorphic blur by using a large x-value. For large values, you may need to increase
124128
/// [`Bloom::max_mip_dimension`] to reduce sampling artifacts.
@@ -148,6 +152,7 @@ impl Bloom {
148152
max_mip_dimension: Self::DEFAULT_MAX_MIP_DIMENSION,
149153
scale: Vec2::ONE,
150154
high_quality: true,
155+
max_mip_count: u32::MAX,
151156
};
152157

153158
/// Emulates the look of stylized anamorphic bloom, stretched horizontally.
@@ -172,6 +177,7 @@ impl Bloom {
172177
max_mip_dimension: Self::DEFAULT_MAX_MIP_DIMENSION,
173178
scale: Vec2::ONE,
174179
high_quality: true,
180+
max_mip_count: u32::MAX,
175181
};
176182

177183
/// A preset that applies a very strong bloom, and blurs the whole screen.
@@ -188,6 +194,7 @@ impl Bloom {
188194
max_mip_dimension: Self::DEFAULT_MAX_MIP_DIMENSION,
189195
scale: Vec2::ONE,
190196
high_quality: true,
197+
max_mip_count: u32::MAX,
191198
};
192199
}
193200

0 commit comments

Comments
 (0)