From 04661cb82fbad22b431867e30b06487b17f51644 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Fri, 7 Jul 2023 18:10:22 -0400 Subject: [PATCH] fix line with perspective --- crates/bevy_gizmos/src/lines.wgsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_gizmos/src/lines.wgsl b/crates/bevy_gizmos/src/lines.wgsl index 037a9fbcaefbf..a5003fd2aeb63 100644 --- a/crates/bevy_gizmos/src/lines.wgsl +++ b/crates/bevy_gizmos/src/lines.wgsl @@ -64,7 +64,7 @@ fn vertex(vertex: VertexInput) -> VertexOutput { #endif // Line thinness fade from https://acegikmo.com/shapes/docs/#anti-aliasing - if line_width < 1. { + if line_width > 0.0 && line_width < 1. { color.a *= line_width; line_width = 1.; } @@ -79,10 +79,10 @@ fn vertex(vertex: VertexInput) -> VertexOutput { let epsilon = 4.88e-04; // depth * (clip.w / depth)^-depth_bias. So that when -depth_bias is 1.0, this is equal to clip.w // and when equal to 0.0, it is exactly equal to depth. - // the epsilon is here to prevent the depth from exceeding clip.w when -depth_bias = 1.0 + // the epsilon is here to prevent the depth from exceeding clip.w when -depth_bias = 1.0 // clip.w represents the near plane in homogenous clip space in bevy, having a depth // of this value means nothing can be in front of this - // The reason this uses an exponential function is that it makes it much easier for the + // The reason this uses an exponential function is that it makes it much easier for the // user to chose a value that is convinient for them depth = clip.z * exp2(-line_gizmo.depth_bias * log2(clip.w / clip.z - epsilon)); }