Skip to content

Commit

Permalink
Fix gap in miter join (#3053)
Browse files Browse the repository at this point in the history
fix gap in miter join
  • Loading branch information
ffreyer committed Jul 11, 2023
1 parent 89dffb3 commit 345a085
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions GLMakie/assets/shader/lines.geom
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,21 @@ vec3 screen_space(vec4 vertex)
// Manual uv calculation
// - position in screen space (double resolution as generally used)
// - uv with uv.u normalized (0..1), uv.v unnormalized (0..pattern_length)
void emit_vertex(vec3 position, vec2 uv, int index)
void emit_vertex(vec3 position, vec2 uv, int index, float thickness)
{
f_uv = uv;
f_color = g_color[index];
gl_Position = vec4((position.xy / resolution), position.z, 1.0);
f_id = g_id[index];
// linewidth scaling may shrink the effective linewidth
f_thickness = abs(uv.y) - AA_THICKNESS;
f_thickness = thickness;
EmitVertex();
}
// default for miter joins
void emit_vertex(vec3 position, vec2 uv, int index)
{
emit_vertex(position, uv, index, g_thickness[index]);
}

// For center point
void emit_vertex(vec3 position, vec2 uv)
Expand All @@ -72,15 +77,20 @@ void emit_vertex(vec3 position, vec2 uv)
}

// Debug
void emit_vertex(vec3 position, vec2 uv, int index, vec4 color)
void emit_vertex(vec3 position, vec2 uv, int index, vec4 color, float thickness)
{
f_uv = uv;
f_color = color;
gl_Position = vec4((position.xy / resolution), position.z, 1.0);
f_id = g_id[index];
f_thickness = abs(uv.y) - AA_THICKNESS;
f_thickness = thickness;
EmitVertex();
}
// default for miter joins
void emit_vertex(vec3 position, vec2 uv , int index, vec4 color)
{
emit_vertex(position, uv , index, color, g_thickness[index]);
}
void emit_vertex(vec3 position, vec2 uv, vec4 color)
{
f_uv = uv;
Expand All @@ -98,8 +108,11 @@ void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv, int index)
emit_vertex(
position + vec3(offset, 0),
vec2(uv.x + px2uv * dot(line_dir, offset), uv.y),
index
index,
abs(uv.y) - AA_THICKNESS
);
// `abs(uv.y) - AA_THICKNESS` corrects for enlarged AA padding between
// segments of different linewidth, see #2953
}

void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv)
Expand Down

0 comments on commit 345a085

Please sign in to comment.