diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-03-20 10:06:35 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2018-03-21 13:26:30 -0700 |
commit | 4dc191b8da139b19c5aa5a705169647786516a20 (patch) | |
tree | bf3b7a8bcf1e12599ad1e3a0606609cb7707a8e8 | |
parent | d4f2bc07ca424fe6c4a596dac91ab247634e7aab (diff) | |
download | qtlocation-mapboxgl-4dc191b8da139b19c5aa5a705169647786516a20.tar.gz |
[core] Avoid flashing on pitched overzoomed tiles.
Clamps perspective ratios in shaders.
Fixes issue #11487.
Port of GL JS PR #6365.
m--------- | mapbox-gl-js | 0 | ||||
-rw-r--r-- | src/mbgl/shaders/collision_box.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/shaders/symbol_icon.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/shaders/symbol_sdf.cpp | 5 |
4 files changed, 12 insertions, 3 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js -Subproject 4cd5570ad3ed3e0ad71e2f795e795a78f5ccf60 +Subproject 11552cf2792ca239b18d7c77663492ead6365cb diff --git a/src/mbgl/shaders/collision_box.cpp b/src/mbgl/shaders/collision_box.cpp index 9d11640bf4..bc5d9bc6f9 100644 --- a/src/mbgl/shaders/collision_box.cpp +++ b/src/mbgl/shaders/collision_box.cpp @@ -22,7 +22,10 @@ varying float v_notUsed; void main() { vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1); highp float camera_to_anchor_distance = projectedPoint.w; - highp float collision_perspective_ratio = 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance); + highp float collision_perspective_ratio = clamp( + 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance), + 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles + 4.0); gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0); gl_Position.xy += a_extrude * u_extrude_scale * gl_Position.w * collision_perspective_ratio; diff --git a/src/mbgl/shaders/symbol_icon.cpp b/src/mbgl/shaders/symbol_icon.cpp index f5c2bbe22d..da31d36291 100644 --- a/src/mbgl/shaders/symbol_icon.cpp +++ b/src/mbgl/shaders/symbol_icon.cpp @@ -80,7 +80,10 @@ void main() { highp float distance_ratio = u_pitch_with_map ? camera_to_anchor_distance / u_camera_to_center_distance : u_camera_to_center_distance / camera_to_anchor_distance; - highp float perspective_ratio = 0.5 + 0.5 * distance_ratio; + highp float perspective_ratio = clamp( + 0.5 + 0.5 * distance_ratio, + 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles + 4.0); size *= perspective_ratio; diff --git a/src/mbgl/shaders/symbol_sdf.cpp b/src/mbgl/shaders/symbol_sdf.cpp index 441eaf7aac..46bab10be5 100644 --- a/src/mbgl/shaders/symbol_sdf.cpp +++ b/src/mbgl/shaders/symbol_sdf.cpp @@ -156,7 +156,10 @@ void main() { highp float distance_ratio = u_pitch_with_map ? camera_to_anchor_distance / u_camera_to_center_distance : u_camera_to_center_distance / camera_to_anchor_distance; - highp float perspective_ratio = 0.5 + 0.5 * distance_ratio; + highp float perspective_ratio = clamp( + 0.5 + 0.5 * distance_ratio, + 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles + 4.0); size *= perspective_ratio; |