summaryrefslogtreecommitdiff
path: root/src/mbgl/programs/gl/line_sdf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/programs/gl/line_sdf.cpp')
-rw-r--r--src/mbgl/programs/gl/line_sdf.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mbgl/programs/gl/line_sdf.cpp b/src/mbgl/programs/gl/line_sdf.cpp
index e6241db9c4..aa72823ae7 100644
--- a/src/mbgl/programs/gl/line_sdf.cpp
+++ b/src/mbgl/programs/gl/line_sdf.cpp
@@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<LineSDFProgram> {
static constexpr const char* name = "line_sdf";
- static constexpr const uint8_t hash[8] = { 0x66, 0x20, 0x75, 0x4e, 0xbe, 0x02, 0x9e, 0x67 };
- static constexpr const auto vertexOffset = 43203;
- static constexpr const auto fragmentOffset = 46817;
+ static constexpr const uint8_t hash[8] = { 0x21, 0x0f, 0x62, 0x9d, 0x31, 0x97, 0xad, 0x16 };
+ static constexpr const auto vertexOffset = 43478;
+ static constexpr const auto fragmentOffset = 47126;
};
constexpr const char* ShaderSource<LineSDFProgram>::name;
@@ -51,20 +51,17 @@ Context::createProgram<gl::Context>(const ProgramParameters& programParameters)
// long distances for long segments. Use this value to unscale the distance.
#define LINE_DISTANCE_SCALE 2.0
-// the distance over which the line edge fades out.
-// Retina devices need a smaller distance to avoid aliasing.
-#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0
-
attribute vec4 a_pos_normal;
attribute vec4 a_data;
uniform mat4 u_matrix;
uniform mediump float u_ratio;
+uniform lowp float u_device_pixel_ratio;
uniform vec2 u_patternscale_a;
uniform float u_tex_y_a;
uniform vec2 u_patternscale_b;
uniform float u_tex_y_b;
-uniform vec2 u_gl_units_to_pixels;
+uniform vec2 u_units_to_pixels;
varying vec2 v_normal;
varying vec2 v_width2;
@@ -185,6 +182,10 @@ void main() {
#endif
+ // 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;
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
@@ -222,7 +223,7 @@ void main() {
// calculate how much the perspective view squishes or stretches the extrude
float extrude_length_without_perspective = length(dist);
- float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);
+ float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a);
@@ -236,6 +237,7 @@ void main() {
// Uncompressed source of line_sdf.fragment.glsl:
/*
+uniform lowp float u_device_pixel_ratio;
uniform sampler2D u_image;
uniform float u_sdfgamma;
uniform float u_mix;
@@ -315,7 +317,7 @@ void main() {
// Calculate the antialiasing fade factor. This is either when fading in
// the line in case of an offset line (v_width2.t) or when fading out
// (v_width2.s)
- float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
+ float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
float sdfdist_a = texture2D(u_image, v_tex_a).a;