Fix: Add SyncComponents for SSAO, ensuring SSAOResources is synced (#24086)

# Objective

- The SSAO part of the fix for #24084 

## Solution

- Add SSAOResources (and other related components) to the sync component
target for SSAO to ensure that adding/removing SSAO also adds/removes
resources. This ensures that checking for SSAOResources later in
`mesh_view_bindings` logic is valid.

## Testing

- `cargo run --example ssao` : toggling “Off” no longer crashes.
This commit is contained in:
Kevin Chen
2026-05-03 19:54:26 -04:00
committed by GitHub
parent e626337b00
commit d00313ed55
+12 -6
View File
@@ -111,6 +111,7 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin {
#[derive(Component, ExtractComponent, Reflect, PartialEq, Clone, Debug)]
#[reflect(Component, Debug, Default, PartialEq, Clone)]
#[require(DepthPrepass, NormalPrepass)]
#[extract_component_sync_target((Self, ScreenSpaceAmbientOcclusionResources, SsaoPipelineId, SsaoBindGroups))]
#[doc(alias = "Ssao")]
pub struct ScreenSpaceAmbientOcclusion {
/// Quality of the SSAO effect.
@@ -598,8 +599,9 @@ fn prepare_ssao_textures(
}
}
/// A render world component that holds the cached pipeline id for Ssao.
#[derive(Component)]
struct SsaoPipelineId(CachedComputePipelineId);
pub struct SsaoPipelineId(pub CachedComputePipelineId);
fn prepare_ssao_pipelines(
mut commands: Commands,
@@ -622,12 +624,16 @@ fn prepare_ssao_pipelines(
}
}
/// A render world component that stores the bind groups necessary to perform
/// Screen Space Ambient Occlusion.
///
/// This is stored on each view.
#[derive(Component)]
struct SsaoBindGroups {
common_bind_group: BindGroup,
preprocess_depth_bind_group: BindGroup,
ssao_bind_group: BindGroup,
spatial_denoise_bind_group: BindGroup,
pub struct SsaoBindGroups {
pub common_bind_group: BindGroup,
pub preprocess_depth_bind_group: BindGroup,
pub ssao_bind_group: BindGroup,
pub spatial_denoise_bind_group: BindGroup,
}
fn prepare_ssao_bind_groups(