From 0351b05978abb08ec3109c83cf7f739a551ab901 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Fri, 27 Oct 2023 21:44:09 +0100 Subject: [PATCH] Fix Z-fighting in the flying_objects example. --- src/pipeline.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pipeline.rs b/src/pipeline.rs index c4e329d..57674cf 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -355,15 +355,16 @@ impl SpecializedMeshPipeline for OutlinePipeline { depth_write_enabled: true, depth_compare: CompareFunction::Greater, stencil: StencilState::default(), - bias: DepthBiasState { - constant: if key.depth_mode() == DepthMode::Flat - && key.pass_type() == PassType::Stencil - { - 2 // 1 is empirically not enough to prevent Z-fighting. - } else { - 0 - }, - ..default() + bias: if key.depth_mode() == DepthMode::Flat && key.pass_type() == PassType::Stencil + { + DepthBiasState { + // Values determined empirically + constant: 3, + slope_scale: 1.0, + ..default() + } + } else { + default() }, }), multisample: MultisampleState {