diff --git a/WGLMakie/assets/lines.frag b/WGLMakie/assets/lines.frag deleted file mode 100644 index b146e66af6c..00000000000 --- a/WGLMakie/assets/lines.frag +++ /dev/null @@ -1,47 +0,0 @@ -precision mediump int; -precision mediump float; -precision mediump sampler2D; -precision mediump sampler3D; - -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; -in float f_thickness; - -uniform float pattern_length; - -out vec4 fragment_color; - -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 - -float aastep(float threshold1, float dist) { - return smoothstep(threshold1 - ANTIALIAS_RADIUS, threshold1 + ANTIALIAS_RADIUS, dist); -} - -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0f * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} - -float aastep_scaled(float threshold1, float threshold2, float dist) { - float AA = ANTIALIAS_RADIUS / pattern_length; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} - -void main() { - vec4 color = vec4(f_color.rgb, 0.0f); - vec2 xy = f_uv; - - float alpha = aastep(0.0f, xy.x); - float alpha2 = aastep(-f_thickness, f_thickness, xy.y); - float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); - - color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); - - fragment_color = color; -} diff --git a/WGLMakie/assets/lines.vert b/WGLMakie/assets/lines.vert deleted file mode 100644 index bb22d732b75..00000000000 --- a/WGLMakie/assets/lines.vert +++ /dev/null @@ -1,82 +0,0 @@ -in float position; -in vec2 linepoint_prev; -in vec2 linepoint_start; -in vec2 linepoint_end; -in vec2 linepoint_next; -in float linewidth_prev; -in float linewidth_start; -in float linewidth_end; -in float linewidth_next; - -uniform vec4 is_valid; -uniform vec4 color_end; -uniform vec4 color_start; -uniform mat4 model; -uniform mat4 projectionview; -uniform vec2 resolution; - -out vec2 f_uv; -out vec4 f_color; -out float f_thickness; - -vec3 screen_space(vec3 point) { - vec4 vertex = projectionview * model * vec4(point, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; -} - -vec3 screen_space(vec2 point) { - return screen_space(vec3(point, 0)); -} - - -void emit_vertex(vec3 position, vec2 uv, bool is_start) { - - f_uv = uv; - - f_color = is_start ? color_start : color_end; - - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - // linewidth scaling may shrink the effective linewidth - f_thickness = is_start ? linewidth_start : linewidth_end; -} - -void main() { - vec3 p1 = screen_space(linepoint_start); - vec3 p2 = screen_space(linepoint_end); - vec2 dir = p1.xy - p2.xy; - dir = normalize(dir); - vec2 line_normal = vec2(dir.y, -dir.x); - vec2 line_offset = line_normal * (linewidth_start / 2.0); - - // triangle 1 - vec3 v0 = vec3(p1.xy - line_offset, p1.z); - if (position == 0.0) { - emit_vertex(v0, vec2(0.0, 0.0), true); - return; - } - vec3 v2 = vec3(p2.xy - line_offset, p2.z); - if (position == 1.0) { - emit_vertex(v2, vec2(0.0, 0.0), false); - return; - } - vec3 v1 = vec3(p1.xy + line_offset, p1.z); - if (position == 2.0) { - emit_vertex(v1, vec2(0.0, 0.0), true); - return; - } - - // triangle 2 - if (position == 3.0) { - emit_vertex(v2, vec2(0.0, 0.0), false); - return; - } - vec3 v3 = vec3(p2.xy + line_offset, p2.z); - if (position == 4.0) { - emit_vertex(v3, vec2(0.0, 0.0), false); - return; - } - if (position == 5.0) { - emit_vertex(v1, vec2(0.0, 0.0), true); - return; - } -} diff --git a/WGLMakie/src/mapbox-lines.vert b/WGLMakie/src/mapbox-lines.vert deleted file mode 100644 index d2912bc4d67..00000000000 --- a/WGLMakie/src/mapbox-lines.vert +++ /dev/null @@ -1,74 +0,0 @@ -#version 300 es -precision highp float; -// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define EXTRUDE_SCALE 0.015873016 - -in vec2 a_pos_normal; -in vec4 a_data; - -uniform mat4 u_matrix; -uniform mat2 u_pixels_to_tile_units; -uniform vec2 u_units_to_pixels; -uniform lowp float u_device_pixel_ratio; - -out vec2 v_normal; -out vec2 v_width2; -out float v_gamma_scale; - -lowp float floorwidth = 1.0; -mediump float gapwidth = 0.0; -lowp float offset = 0.0; -float width = 1.0; - -void main() { - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist = outset * a_extrude * EXTRUDE_SCALE; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * EXTRUDE_SCALE * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist * u_pixels_to_tile_units, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 * u_pixels_to_tile_units, 0.0, 1.0) + projected_extrude; - - - v_gamma_scale = 1.0; - - v_width2 = vec2(outset, inset); - -}