Skip to content

Commit 62cfa9e

Browse files
committed
Enable alpha blending for gimzos in 3d
1 parent f6500f5 commit 62cfa9e

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

crates/bevy_gizmos/src/pipeline_2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl SpecializedMeshPipeline for GizmoPipeline2d {
8181
alpha_to_coverage_enabled: false,
8282
},
8383
push_constant_ranges: vec![],
84-
label: None,
84+
label: Some("gizmo_2d_pipeline".into()),
8585
})
8686
}
8787
}

crates/bevy_gizmos/src/pipeline_3d.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,6 @@ impl SpecializedMeshPipeline for GizmoPipeline3d {
6464
Mesh::ATTRIBUTE_POSITION.at_shader_location(0),
6565
Mesh::ATTRIBUTE_COLOR.at_shader_location(1),
6666
])?;
67-
let (label, blend, depth_write_enabled);
68-
if key.contains(MeshPipelineKey::BLEND_PREMULTIPLIED_ALPHA) {
69-
label = "transparent_gizmo_pipeline".into();
70-
blend = Some(BlendState::ALPHA_BLENDING);
71-
// For the transparent pass, fragments that are closer will be alpha
72-
// blended but their depth is not written to the depth buffer.
73-
depth_write_enabled = false;
74-
} else {
75-
label = "opaque_gizmo_pipeline".into();
76-
blend = Some(BlendState::REPLACE);
77-
// For the opaque and alpha mask passes, fragments that are closer
78-
// will replace the current fragment value in the output and the depth is
79-
// written to the depth buffer.
80-
depth_write_enabled = true;
81-
}
8267
let bind_group_layout = match key.msaa_samples() {
8368
1 => vec![self.mesh_pipeline.view_layout.clone()],
8469
_ => {
@@ -106,7 +91,7 @@ impl SpecializedMeshPipeline for GizmoPipeline3d {
10691
entry_point: "fragment".into(),
10792
targets: vec![Some(ColorTargetState {
10893
format,
109-
blend,
94+
blend: Some(BlendState::ALPHA_BLENDING),
11095
write_mask: ColorWrites::ALL,
11196
})],
11297
}),
@@ -122,7 +107,7 @@ impl SpecializedMeshPipeline for GizmoPipeline3d {
122107
},
123108
depth_stencil: Some(DepthStencilState {
124109
format: TextureFormat::Depth32Float,
125-
depth_write_enabled,
110+
depth_write_enabled: false,
126111
depth_compare: CompareFunction::Greater,
127112
stencil: StencilState {
128113
front: StencilFaceState::IGNORE,
@@ -142,7 +127,7 @@ impl SpecializedMeshPipeline for GizmoPipeline3d {
142127
alpha_to_coverage_enabled: false,
143128
},
144129
push_constant_ranges: vec![],
145-
label: Some(label),
130+
label: Some("gizmo_3d_pipeline".into()),
146131
})
147132
}
148133
}

0 commit comments

Comments
 (0)