diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index 69a32acd75f5b..a639644463a33 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -25,6 +25,7 @@ use bevy_ecs::{ }; use bevy_image::BevyDefault as _; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_render::render_graph::RenderGraph; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, @@ -233,8 +234,20 @@ impl Plugin for ScreenSpaceReflectionsPlugin { render_app .init_resource::() - .init_resource::>() - .add_render_graph_edges( + .init_resource::>(); + + // only reference the default deferred lighting pass + // if it has been added + let has_default_deferred_lighting_pass = render_app + .world_mut() + .get_resource_mut::() + .unwrap() + .sub_graph(Core3d) + .get_node_state(NodePbr::DeferredLightingPass) + .is_ok(); + + if has_default_deferred_lighting_pass { + render_app.add_render_graph_edges( Core3d, ( NodePbr::DeferredLightingPass, @@ -242,6 +255,12 @@ impl Plugin for ScreenSpaceReflectionsPlugin { Node3d::MainOpaquePass, ), ); + } else { + render_app.add_render_graph_edges( + Core3d, + (NodePbr::ScreenSpaceReflections, Node3d::MainOpaquePass), + ); + } } }