From 2358a63c470e4dae1bd85e1f816e6caed26feff9 Mon Sep 17 00:00:00 2001 From: Justin Willmert Date: Sat, 7 Jan 2023 13:42:54 -0600 Subject: [PATCH] Revert including scaling factors in line rendering After identifying failing tests, closer reading suggests the line rendering shaders all work in normalized units that arise naturally from comparing the framebuffer size to resolution factor. This means adding additional scaling is unnecessary since the framebuffer size is already scaled. --- GLMakie/assets/shader/line_segment.geom | 15 +++++++-------- GLMakie/assets/shader/lines.geom | 11 +++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/GLMakie/assets/shader/line_segment.geom b/GLMakie/assets/shader/line_segment.geom index 104a69aa0de..a9e7d8b4fe2 100644 --- a/GLMakie/assets/shader/line_segment.geom +++ b/GLMakie/assets/shader/line_segment.geom @@ -5,7 +5,6 @@ layout(lines) in; layout(triangle_strip, max_vertices = 4) out; uniform vec2 resolution; -uniform float px_per_unit; uniform float maxlength; uniform float thickness; uniform float pattern_length; @@ -23,7 +22,7 @@ flat out uvec2 f_id; vec2 screen_space(vec4 vertex) { - return vec2(vertex.xy / vertex.w) * resolution*px_per_unit; + return vec2(vertex.xy / vertex.w) * resolution; } void emit_vertex(vec2 position, vec2 uv, int index) @@ -31,9 +30,9 @@ void emit_vertex(vec2 position, vec2 uv, int index) vec4 inpos = gl_in[index].gl_Position; f_uv = uv; f_color = g_color[index]; - gl_Position = vec4((position / (resolution*px_per_unit)) * inpos.w, inpos.z, inpos.w); + gl_Position = vec4((position / resolution) * inpos.w, inpos.z, inpos.w); f_id = g_id[index]; - f_thickness = px_per_unit * g_thickness[index] + AA_THICKNESS; + f_thickness = g_thickness[index] + AA_THICKNESS; EmitVertex(); } @@ -50,8 +49,8 @@ void main(void) vec2 p0 = screen_space(gl_in[0].gl_Position); // start of previous segment vec2 p1 = screen_space(gl_in[1].gl_Position); // end of previous segment, start of current segment - float thickness_aa0 = px_per_unit * g_thickness[0] + AA_THICKNESS; - float thickness_aa1 = px_per_unit * g_thickness[1] + AA_THICKNESS; + float thickness_aa0 = g_thickness[0] + AA_THICKNESS; + float thickness_aa1 = g_thickness[1] + AA_THICKNESS; // determine the direction of each of the 3 segments (previous, current, next) vec2 vun0 = p1 - p0; vec2 v0 = normalize(vun0); @@ -60,8 +59,8 @@ void main(void) float l = length(p1-p0); l /= (pattern_length*10); - float uv0 = thickness_aa0 / px_per_unit*g_thickness[0]; - float uv1 = thickness_aa1 / px_per_unit*g_thickness[1]; + float uv0 = thickness_aa0 / g_thickness[0]; + float uv1 = thickness_aa1 / g_thickness[1]; emit_vertex(p0 + thickness_aa0 * n0, vec2(0, -uv0), 0); emit_vertex(p0 - thickness_aa0 * n0, vec2(0, uv0), 0); emit_vertex(p1 + thickness_aa1 * n0, vec2(l, -uv1), 1); diff --git a/GLMakie/assets/shader/lines.geom b/GLMakie/assets/shader/lines.geom index ac8cf6171b8..d6770e58ae1 100644 --- a/GLMakie/assets/shader/lines.geom +++ b/GLMakie/assets/shader/lines.geom @@ -19,7 +19,6 @@ out float f_thickness; flat out uvec2 f_id; uniform vec2 resolution; -uniform float px_per_unit; uniform float maxlength; uniform float thickness; uniform float pattern_length; @@ -29,16 +28,16 @@ uniform float pattern_length; vec2 screen_space(vec4 vertex) { - return vec2(vertex.xy / vertex.w) * resolution*px_per_unit; + return vec2(vertex.xy / vertex.w) * resolution; } void emit_vertex(vec2 position, vec2 uv, int index, float ratio) { vec4 inpos = gl_in[index].gl_Position; f_uv = vec2((g_lastlen[index] * ratio) / pattern_length / (thickness+4) / 2.0, uv.y); f_color = g_color[index]; - gl_Position = vec4((position / (resolution*px_per_unit)) * inpos.w, inpos.z, inpos.w); + gl_Position = vec4((position / resolution) * inpos.w, inpos.z, inpos.w); f_id = g_id[index]; - f_thickness = px_per_unit * thickness; + f_thickness = thickness; EmitVertex(); } @@ -76,7 +75,7 @@ void main(void) vec2 p2 = screen_space(gl_in[2].gl_Position); // end of current segment, start of next segment vec2 p3 = screen_space(gl_in[3].gl_Position); // end of next segment - float thickness_aa = px_per_unit * thickness + 4; + float thickness_aa = thickness + 4; // determine the direction of each of the 3 segments (previous, current, next) vec2 v1 = normalize(p2 - p1); @@ -127,7 +126,7 @@ void main(void) float xend = g_lastlen[2]; float ratio = length(p2 - p1) / (xend - xstart); - float uvy = thickness_aa / (px_per_unit * thickness); + float uvy = thickness_aa / thickness; if( dot( v0, v1 ) < MITER_LIMIT ){ /*