pub struct BloomSettings {
    pub intensity: f32,
    pub low_frequency_boost: f32,
    pub low_frequency_boost_curvature: f32,
    pub high_pass_frequency: f32,
    pub prefilter_settings: BloomPrefilterSettings,
    pub composite_mode: BloomCompositeMode,
}
Expand description

Applies a bloom effect to an HDR-enabled 2d or 3d camera.

Bloom emulates an effect found in real cameras and the human eye, causing halos to appear around very bright parts of the scene.

See also https://en.wikipedia.org/wiki/Bloom_(shader_effect).

Usage Notes

Bloom is currently not compatible with WebGL2.

Often used in conjunction with bevy_pbr::StandardMaterial::emissive for 3d meshes.

Bloom is best used alongside a tonemapping function that desaturates bright colors, such as crate::tonemapping::Tonemapping::TonyMcMapface.

Bevy’s implementation uses a parametric curve to blend between a set of blurred (lower frequency) images generated from the camera’s view. See https://starlederer.github.io/bloom/ for a visualization of the parametric curve used in Bevy as well as a visualization of the curve’s respective scattering profile.

Fields§

§intensity: f32

Controls the baseline of how much the image is scattered (default: 0.15).

This parameter should be used only to control the strength of the bloom for the scene as a whole. Increasing it too much will make the scene appear blurry and over-exposed.

To make a mesh glow brighter, rather than increase the bloom intensity, you should increase the mesh’s emissive value.

In energy-conserving mode

The value represents how likely the light is to scatter.

The value should be between 0.0 and 1.0 where:

  • 0.0 means no bloom
  • 1.0 means the light is scattered as much as possible

In additive mode

The value represents how much scattered light is added to the image to create the glow effect.

In this configuration:

  • 0.0 means no bloom
  • 0.0 means a proportionate amount of scattered light is added

§low_frequency_boost: f32

Low frequency contribution boost. Controls how much more likely the light is to scatter completely sideways (low frequency image).

Comparable to a low shelf boost on an equalizer.

In energy-conserving mode

The value should be between 0.0 and 1.0 where:

  • 0.0 means low frequency light uses base intensity for blend factor calculation
  • 1.0 means low frequency light contributes at full power

In additive mode

The value represents how much scattered light is added to the image to create the glow effect.

In this configuration:

  • 0.0 means no bloom
  • 0.0 means a proportionate amount of scattered light is added

§low_frequency_boost_curvature: f32

Low frequency contribution boost curve. Controls the curvature of the blend factor function making frequencies next to the lowest ones contribute more.

Somewhat comparable to the Q factor of an equalizer node.

Valid range:

  • 0.0 - base base intensity and boosted intensity are linearly interpolated
  • 1.0 - all frequencies below maximum are at boosted intensity level
§high_pass_frequency: f32

Tightens how much the light scatters (default: 1.0).

Valid range:

  • 0.0 - maximum scattering angle is 0 degrees (no scattering)
  • 1.0 - maximum scattering angle is 90 degrees
§prefilter_settings: BloomPrefilterSettings§composite_mode: BloomCompositeMode

Controls whether bloom textures are blended between or added to each other. Useful if image brightening is desired and a must-change if prefilter_settings are used.

Recommendation

Set to BloomCompositeMode::Additive if prefilter_settings are configured in a non-energy-conserving way, otherwise set to BloomCompositeMode::EnergyConserving.

Implementations§

§

impl BloomSettings

pub const NATURAL: BloomSettings = Self{ intensity: 0.15, low_frequency_boost: 0.7, low_frequency_boost_curvature: 0.95, high_pass_frequency: 1.0, prefilter_settings: BloomPrefilterSettings{ threshold: 0.0, threshold_softness: 0.0,}, composite_mode: BloomCompositeMode::EnergyConserving,}

The default bloom preset.

pub const OLD_SCHOOL: BloomSettings = Self{ intensity: 0.05, low_frequency_boost: 0.7, low_frequency_boost_curvature: 0.95, high_pass_frequency: 1.0, prefilter_settings: BloomPrefilterSettings{ threshold: 0.6, threshold_softness: 0.2,}, composite_mode: BloomCompositeMode::Additive,}

A preset that’s similiar to how older games did bloom.

pub const SCREEN_BLUR: BloomSettings = Self{ intensity: 1.0, low_frequency_boost: 0.0, low_frequency_boost_curvature: 0.0, high_pass_frequency: 1.0 / 3.0, prefilter_settings: BloomPrefilterSettings{ threshold: 0.0, threshold_softness: 0.0,}, composite_mode: BloomCompositeMode::EnergyConserving,}

A preset that applies a very strong bloom, and blurs the whole screen.

Trait Implementations§

§

impl Clone for BloomSettings

§

fn clone(&self) -> BloomSettings

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Component for BloomSettingswhere BloomSettings: Send + Sync + 'static,

§

impl Default for BloomSettings

§

fn default() -> BloomSettings

Returns the “default value” for a type. Read more
§

impl ExtractComponent for BloomSettings

§

type Query = (&'static BloomSettings, &'static Camera)

ECS WorldQuery to fetch the components to extract.
§

type Filter = ()

Filters the entities with additional constraints.
§

type Out = (BloomSettings, BloomUniforms)

The output from extraction. Read more
§

fn extract_component( _: <<BloomSettings as ExtractComponent>::Query as WorldQuery>::Item<'_> ) -> Option<<BloomSettings as ExtractComponent>::Out>

Defines how the component is transferred into the “render world”.
§

impl GetTypeRegistration for BloomSettingswhere f32: Reflect, BloomPrefilterSettings: Reflect, BloomCompositeMode: Reflect,

§

impl Reflect for BloomSettingswhere f32: Reflect, BloomPrefilterSettings: Reflect, BloomCompositeMode: Reflect,

§

fn type_name(&self) -> &str

Returns the type name of the underlying type.
§

fn get_type_info(&self) -> &'static TypeInfo

Returns the TypeInfo of the underlying type. Read more
§

fn into_any(self: Box<BloomSettings, Global>) -> Box<dyn Any + 'static, Global>

Returns the value as a Box<dyn Any>.
§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any.
§

fn into_reflect( self: Box<BloomSettings, Global> ) -> Box<dyn Reflect + 'static, Global>

Casts this type to a boxed reflected value.
§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a reflected value.
§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable reflected value.
§

fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>

Clones the value as a Reflect trait object. Read more
§

fn set( &mut self, value: Box<dyn Reflect + 'static, Global> ) -> Result<(), Box<dyn Reflect + 'static, Global>>

Performs a type-checked assignment of a reflected value to this value. Read more
§

fn apply(&mut self, value: &(dyn Reflect + 'static))

Applies a reflected value to this value. Read more
§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an enumeration of “kinds” of type. Read more
§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
§

fn reflect_owned(self: Box<BloomSettings, Global>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
§

fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>

Returns a “partial equality” comparison result. Read more
§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
§

fn serializable(&self) -> Option<Serializable<'_>>

Returns a serializable version of the value. Read more
§

impl Struct for BloomSettingswhere f32: Reflect, BloomPrefilterSettings: Reflect, BloomCompositeMode: Reflect,

§

fn field(&self, name: &str) -> Option<&(dyn Reflect + 'static)>

Returns a reference to the value of the field named name as a &dyn Reflect.
§

fn field_mut(&mut self, name: &str) -> Option<&mut (dyn Reflect + 'static)>

Returns a mutable reference to the value of the field named name as a &mut dyn Reflect.
§

fn field_at(&self, index: usize) -> Option<&(dyn Reflect + 'static)>

Returns a reference to the value of the field with index index as a &dyn Reflect.
§

fn field_at_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>

Returns a mutable reference to the value of the field with index index as a &mut dyn Reflect.
§

fn name_at(&self, index: usize) -> Option<&str>

Returns the name of the field with index index.
§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
§

fn iter_fields(&self) -> FieldIter<'_>

Returns an iterator over the values of the reflectable fields for this struct.
§

fn clone_dynamic(&self) -> DynamicStruct

Clones the struct into a DynamicStruct.
§

impl Typed for BloomSettingswhere f32: Reflect, BloomPrefilterSettings: Reflect, BloomCompositeMode: Reflect,

§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,

§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<C> Bundle for Cwhere C: Component,

§

fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )

§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a, Aligned>,

§

fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_, Aligned>) )

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> FromWorld for Twhere T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given World
§

impl<S> GetField for Swhere S: Struct,

§

fn get_field<T>(&self, name: &str) -> Option<&T>where T: Reflect,

Returns a reference to the value of the field named name, downcast to T.
§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>where T: Reflect,

Returns a mutable reference to the value of the field named name, downcast to T.
§

impl<T> GetPath for Twhere T: Reflect,

§

fn reflect_path<'r, 'p>( &'r self, path: &'p str ) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
§

fn reflect_path_mut<'r, 'p>( &'r mut self, path: &'p str ) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
§

fn path<T, 'r, 'p>( &'r self, path: &'p str ) -> Result<&'r T, ReflectPathError<'p>>where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
§

fn path_mut<T, 'r, 'p>( &'r mut self, path: &'p str ) -> Result<&'r mut T, ReflectPathError<'p>>where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> TypeData for Twhere T: 'static + Send + Sync + Clone,

§

fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>

§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,

§

impl<T> Event for Twhere T: Send + Sync + 'static,