Skip to content

Commit

Permalink
bevy_pbr: Clear fog DynamicUniformBuffer before populating each frame (
Browse files Browse the repository at this point in the history
…bevyengine#7432)

# Objective

- Fix a bug causing performance to drop over time because the GPU fog buffer was endlessly growing

## Solution

- Clear the fog buffer every frame before populating it
  • Loading branch information
superdump authored and ItsDoot committed Feb 1, 2023
1 parent ebc0312 commit 92c6b71
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/bevy_pbr/src/render/fog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub fn prepare_fog(
mut fog_meta: ResMut<FogMeta>,
views: Query<(Entity, Option<&FogSettings>), With<ExtractedView>>,
) {
fog_meta.gpu_fogs.clear();

for (entity, fog) in &views {
let gpu_fog = if let Some(fog) = fog {
match &fog.falloff {
Expand Down

0 comments on commit 92c6b71

Please sign in to comment.