diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index a515a2917ddd0..abf3e32220d8c 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,19 @@ 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() + .resource_mut::() + .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 +254,12 @@ impl Plugin for ScreenSpaceReflectionsPlugin { Node3d::MainOpaquePass, ), ); + } else { + render_app.add_render_graph_edges( + Core3d, + (NodePbr::ScreenSpaceReflections, Node3d::MainOpaquePass), + ); + } } }