From e5994a4e55a66a6682c02d41706dc1b611435291 Mon Sep 17 00:00:00 2001 From: Sludge <96552222+SludgePhD@users.noreply.github.com> Date: Sun, 25 Feb 2024 23:34:05 +0100 Subject: [PATCH] Early-exit bloom node if `intensity == 0.0` (#12113) # Objective - The bloom effect is currently somewhat costly (in terms of GPU time used), due to using fragment shaders for down- and upscaling (compute shaders generally perform better for such tasks). - Additionally, one might have a `BloomSettings` on a camera whose `intensity` is only occasionally set to a non-zero value (eg. in outside areas or areas with bright lighting). Currently, the cost of the bloom shader is always incurred as long as the `BloomSettings` exists. ## Solution - Bail out of the bloom render node when `intensity == 0.0`, making the effect free as long as it is turned all the way down. --- crates/bevy_core_pipeline/src/bloom/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index c76ea78934..2896e86e1e 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -129,6 +129,10 @@ impl ViewNode for BloomNode { ): QueryItem, world: &World, ) -> Result<(), NodeRunError> { + if bloom_settings.intensity == 0.0 { + return Ok(()); + } + let downsampling_pipeline_res = world.resource::(); let pipeline_cache = world.resource::(); let uniforms = world.resource::>();