Skip to content

Commit

Permalink
Don't ignore depth in prepass
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Nov 10, 2023
1 parent b8aad9c commit 104742e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/deferred/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use bevy_render::{
use bevy_utils::tracing::info_span;

use crate::core_3d::{Camera3d, Camera3dDepthLoadOp};
use crate::prepass::{DepthPrepass, MotionVectorPrepass, NormalPrepass, ViewPrepassTextures};
use crate::prepass::{MotionVectorPrepass, NormalPrepass, ViewPrepassTextures};

use super::{AlphaMask3dDeferred, Opaque3dDeferred};

Expand Down
14 changes: 11 additions & 3 deletions crates/bevy_core_pipeline/src/prepass/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use bevy_render::{
#[cfg(feature = "trace")]
use bevy_utils::tracing::info_span;

use crate::core_3d::{Camera3d, Camera3dDepthLoadOp};

use super::{AlphaMask3dPrepass, DeferredPrepass, Opaque3dPrepass, ViewPrepassTextures};

/// Render node used by the prepass.
Expand All @@ -27,6 +29,7 @@ pub struct PrepassNode;
impl ViewNode for PrepassNode {
type ViewQuery = (
&'static ExtractedCamera,
&'static Camera3d,
&'static RenderPhase<Opaque3dPrepass>,
&'static RenderPhase<AlphaMask3dPrepass>,
&'static ViewDepthTexture,
Expand All @@ -40,6 +43,7 @@ impl ViewNode for PrepassNode {
render_context: &mut RenderContext,
(
camera,
camera_3d,
opaque_prepass_phase,
alpha_mask_prepass_phase,
view_depth_texture,
Expand All @@ -50,8 +54,6 @@ impl ViewNode for PrepassNode {
) -> Result<(), NodeRunError> {
let view_entity = graph.view_entity();

let _ = view_depth_texture.is_first_write();

let mut color_attachments = vec![
view_prepass_textures
.normal
Expand Down Expand Up @@ -96,7 +98,13 @@ impl ViewNode for PrepassNode {
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &view_depth_texture.view,
depth_ops: Some(Operations {
load: LoadOp::Clear(0.0),
load: if view_depth_texture.is_first_write() {
// NOTE: 0.0 is the far plane due to bevy's use of reverse-z projections.
camera_3d.depth_load_op.clone()
} else {
Camera3dDepthLoadOp::Load
}
.into(),
store: true,
}),
stencil_ops: None,
Expand Down

0 comments on commit 104742e

Please sign in to comment.