From 13d0d250a7197f75a53f66212ed601536dfe5b14 Mon Sep 17 00:00:00 2001 From: atlas Date: Fri, 5 Sep 2025 13:14:37 -0400 Subject: [PATCH] Fix gizmos for real this time --- crates/bevy_gizmos/src/lines.wgsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/bevy_gizmos/src/lines.wgsl b/crates/bevy_gizmos/src/lines.wgsl index 1181e3f59cdb8..cf6d5c1db7b4d 100644 --- a/crates/bevy_gizmos/src/lines.wgsl +++ b/crates/bevy_gizmos/src/lines.wgsl @@ -136,8 +136,9 @@ fn vertex(vertex: VertexInput) -> VertexOutput { } fn clip_near_plane(a: vec4, b: vec4) -> vec4 { - // Move a if a is behind the near plane and b is in front. - if a.z > a.w && b.z <= b.w { + // Move a if a is behind the near plane and b is in front. + // equivalent to `a.z / a.w > 1.0 && b.z / b.w <= 1.0` but avoids divs + if a.z * sign(a.w) > abs(a.w) && b.z * sign(b.w) <= abs(b.w) { // Interpolate a towards b until it's at the near plane. let distance_a = a.z - a.w; let distance_b = b.z - b.w;