From ed5968c4cd04926e088209eb28f5273212eeacc7 Mon Sep 17 00:00:00 2001 From: JordanSucher Date: Tue, 21 May 2024 16:41:34 -0400 Subject: [PATCH] modified stroke vertex shader --- src/webgl/shaders/line.vert | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/webgl/shaders/line.vert b/src/webgl/shaders/line.vert index bd608181a9..e9fc624bfc 100644 --- a/src/webgl/shaders/line.vert +++ b/src/webgl/shaders/line.vert @@ -88,19 +88,16 @@ void main() { 0.25 ); - // using a scale <1 moves the lines towards the camera - // in order to prevent popping effects due to half of - // the line disappearing behind the geometry faces. - float scale = mix(1., 0.995, facingCamera); - // Moving vertices slightly toward the camera // to avoid depth-fighting with the fill triangles. - // Discussed here: - // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848 - posp.xyz = posp.xyz * scale; - posqIn.xyz = posqIn.xyz * scale; - posqOut.xyz = posqOut.xyz * scale; - + // This prevents popping effects due to half of + // the line disappearing behind the geometry faces. + + float zOffset = mix(-0.00045, -1., facingCamera); + posp.z -= zOffset; + posqIn.z -= zOffset; + posqOut.z -= zOffset; + vec4 p = uProjectionMatrix * posp; vec4 qIn = uProjectionMatrix * posqIn; vec4 qOut = uProjectionMatrix * posqOut;