summaryrefslogtreecommitdiff
path: root/src/mbgl/shader/line.vertex.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/shader/line.vertex.glsl')
-rw-r--r--src/mbgl/shader/line.vertex.glsl23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/mbgl/shader/line.vertex.glsl b/src/mbgl/shader/line.vertex.glsl
index 1f5432991c..980212384b 100644
--- a/src/mbgl/shader/line.vertex.glsl
+++ b/src/mbgl/shader/line.vertex.glsl
@@ -9,17 +9,17 @@
attribute vec2 a_pos;
attribute vec4 a_data;
-// matrix is for the vertex position, exmatrix is for rotating and projecting
-// the extrusion vector.
uniform mat4 u_matrix;
-uniform mat4 u_exmatrix;
// shared
uniform float u_ratio;
uniform vec2 u_linewidth;
-uniform vec4 u_color;
+
+uniform float u_extra;
+uniform mat2 u_antialiasingmatrix;
varying vec2 v_normal;
+varying float v_gamma_scale;
void main() {
vec2 a_extrude = a_data.xy;
@@ -34,11 +34,22 @@ void main() {
// Scale the extrusion vector down to a normal and then up by the line width
// of this vertex.
- vec4 dist = vec4(u_linewidth.s * a_extrude * scale, 0.0, 0.0);
+ vec2 dist = u_linewidth.s * a_extrude * scale;
// Remove the texture normal bit of the position before scaling it with the
// model/view matrix. Add the extrusion vector *after* the model/view matrix
// because we're extruding the line in pixel space, regardless of the current
// tile's zoom level.
- gl_Position = u_matrix * vec4(floor(a_pos * 0.5), 0.0, 1.0) + u_exmatrix * dist;
+ gl_Position = u_matrix * vec4(floor(a_pos * 0.5) + dist / u_ratio, 0.0, 1.0);
+
+ // position of y on the screen
+ float y = gl_Position.y / gl_Position.w;
+
+ // how much features are squished in the y direction by the tilt
+ float squish_scale = length(a_extrude) / length(u_antialiasingmatrix * a_extrude);
+
+ // how much features are squished in all directions by the perspectiveness
+ float perspective_scale = 1.0 / (1.0 - min(y * u_extra, 0.90));
+
+ v_gamma_scale = perspective_scale * squish_scale;
}