Skip to content

Commit 5e827f0

Browse files
skimmedsquaremockersf
authored andcommitted
Fix 2D Gizmos not always drawn on top (#17085)
# Objective - As stated in the linked issue, if a Mesh2D is drawn with elements with a positive Z value, resulting gizmos get drawn behind instead of in front of them. - Fixes #17053 ## Solution - Similar to the change done for the `SpritePipeline` in the relevant commit (5abc32c), this PR changes both line gizmos to avoid writing to the depth buffer and always pass the depth test to ensure they are not filtered out. ## Testing - Tested with the provided snippet in #17053 - I looked over the `2d_gizmos` example, but it seemed like adding more elements there to demonstrate this might not be the best idea? Looking for guidance here on if that should be updated or if a new gizmo example needs to be made.
1 parent 7056340 commit 5e827f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/bevy_gizmos/src/pipeline_2d.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ impl SpecializedRenderPipeline for LineGizmoPipeline {
140140
primitive: PrimitiveState::default(),
141141
depth_stencil: Some(DepthStencilState {
142142
format: CORE_2D_DEPTH_FORMAT,
143-
depth_write_enabled: true,
144-
depth_compare: CompareFunction::GreaterEqual,
143+
depth_write_enabled: false,
144+
depth_compare: CompareFunction::Always,
145145
stencil: StencilState {
146146
front: StencilFaceState::IGNORE,
147147
back: StencilFaceState::IGNORE,
@@ -241,8 +241,8 @@ impl SpecializedRenderPipeline for LineJointGizmoPipeline {
241241
primitive: PrimitiveState::default(),
242242
depth_stencil: Some(DepthStencilState {
243243
format: CORE_2D_DEPTH_FORMAT,
244-
depth_write_enabled: true,
245-
depth_compare: CompareFunction::GreaterEqual,
244+
depth_write_enabled: false,
245+
depth_compare: CompareFunction::Always,
246246
stencil: StencilState {
247247
front: StencilFaceState::IGNORE,
248248
back: StencilFaceState::IGNORE,

0 commit comments

Comments
 (0)