Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified stroke vertex shader #7064

Merged
merged 1 commit into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/webgl/shaders/line.vert
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading