Skip to content

Commit 8de6b16

Browse files
authored
Implement occlusion culling for the deferred rendering pipeline. (#17934)
Deferred rendering currently doesn't support occlusion culling. This PR implements it in a straightforward way, mirroring what we already do for the non-deferred pipeline. On the rend3 sci-fi base test scene, this resulted in roughly a 2× speedup when applied on top of my other patches. For that scene, it was useful to add another option, `--add-light`, which forces the addition of a shadow-casting light, to the scene viewer, which I included in this patch.
1 parent f15437e commit 8de6b16

File tree

7 files changed

+221
-143
lines changed

7 files changed

+221
-143
lines changed

crates/bevy_core_pipeline/src/core_3d/mod.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ pub mod graph {
1919
EarlyPrepass,
2020
EarlyDownsampleDepth,
2121
LatePrepass,
22-
DeferredPrepass,
22+
EarlyDeferredPrepass,
23+
LateDeferredPrepass,
2324
CopyDeferredLightingId,
2425
EndPrepasses,
2526
StartMainPass,
@@ -112,7 +113,8 @@ use tracing::warn;
112113
use crate::{
113114
core_3d::main_transmissive_pass_3d_node::MainTransmissivePass3dNode,
114115
deferred::{
115-
copy_lighting_id::CopyDeferredLightingIdNode, node::DeferredGBufferPrepassNode,
116+
copy_lighting_id::CopyDeferredLightingIdNode,
117+
node::{EarlyDeferredGBufferPrepassNode, LateDeferredGBufferPrepassNode},
116118
AlphaMask3dDeferred, Opaque3dDeferred, DEFERRED_LIGHTING_PASS_ID_FORMAT,
117119
DEFERRED_PREPASS_FORMAT,
118120
},
@@ -179,9 +181,13 @@ impl Plugin for Core3dPlugin {
179181
.add_render_sub_graph(Core3d)
180182
.add_render_graph_node::<ViewNodeRunner<EarlyPrepassNode>>(Core3d, Node3d::EarlyPrepass)
181183
.add_render_graph_node::<ViewNodeRunner<LatePrepassNode>>(Core3d, Node3d::LatePrepass)
182-
.add_render_graph_node::<ViewNodeRunner<DeferredGBufferPrepassNode>>(
184+
.add_render_graph_node::<ViewNodeRunner<EarlyDeferredGBufferPrepassNode>>(
183185
Core3d,
184-
Node3d::DeferredPrepass,
186+
Node3d::EarlyDeferredPrepass,
187+
)
188+
.add_render_graph_node::<ViewNodeRunner<LateDeferredGBufferPrepassNode>>(
189+
Core3d,
190+
Node3d::LateDeferredPrepass,
185191
)
186192
.add_render_graph_node::<ViewNodeRunner<CopyDeferredLightingIdNode>>(
187193
Core3d,
@@ -210,8 +216,9 @@ impl Plugin for Core3dPlugin {
210216
Core3d,
211217
(
212218
Node3d::EarlyPrepass,
219+
Node3d::EarlyDeferredPrepass,
213220
Node3d::LatePrepass,
214-
Node3d::DeferredPrepass,
221+
Node3d::LateDeferredPrepass,
215222
Node3d::CopyDeferredLightingId,
216223
Node3d::EndPrepasses,
217224
Node3d::StartMainPass,
@@ -943,7 +950,6 @@ fn configure_occlusion_culling_view_targets(
943950
With<OcclusionCulling>,
944951
Without<NoIndirectDrawing>,
945952
With<DepthPrepass>,
946-
Without<DeferredPrepass>,
947953
),
948954
>,
949955
) {

0 commit comments

Comments
 (0)