diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-07-11 11:22:39 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2017-07-12 14:14:09 -0700 |
commit | e8657becc56c2aee5b070357092da028e752d461 (patch) | |
tree | 21a877d6adacfc468b4d2c0223bffec49ea3f5dc /src/mbgl/shaders/symbol_icon.cpp | |
parent | af10e2d3be5f24c1887622c63332a3cf67bc19d5 (diff) | |
download | qtlocation-mapboxgl-e8657becc56c2aee5b070357092da028e752d461.tar.gz |
[core] Update shaders.
Implements 'icon-pitch-alignment' (issue #9345)
Fixes issue #9456 (map-aligned point label regression)
Diffstat (limited to 'src/mbgl/shaders/symbol_icon.cpp')
-rw-r--r-- | src/mbgl/shaders/symbol_icon.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mbgl/shaders/symbol_icon.cpp b/src/mbgl/shaders/symbol_icon.cpp index cb00cdad05..c0e3a0ac01 100644 --- a/src/mbgl/shaders/symbol_icon.cpp +++ b/src/mbgl/shaders/symbol_icon.cpp @@ -19,6 +19,8 @@ uniform highp float u_size_t; // used to interpolate between zoom stops when siz uniform highp float u_size; // used when size is both zoom and feature constant uniform highp float u_camera_to_center_distance; uniform highp float u_pitch; +uniform bool u_rotate_symbol; +uniform highp float u_aspect_ratio; uniform highp float u_collision_y_stretch; @@ -83,8 +85,19 @@ void main() { float fontScale = u_is_text ? size / 24.0 : size; - highp float angle_sin = sin(segment_angle); - highp float angle_cos = cos(segment_angle); + highp float symbol_rotation = 0.0; + if (u_rotate_symbol) { + // See comments in symbol_sdf.vertex + vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); + + vec2 a = projectedPoint.xy / projectedPoint.w; + vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; + + symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); + } + + highp float angle_sin = sin(segment_angle + symbol_rotation); + highp float angle_cos = cos(segment_angle + symbol_rotation); mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); |