Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Avoid flashing on pitched overzoomed tiles.
Browse files Browse the repository at this point in the history
Clamps perspective ratios in shaders.
Fixes issue #11487.
Port of GL JS PR #6365.
  • Loading branch information
ChrisLoer committed Mar 20, 2018
1 parent a225009 commit 0a15448
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 78 files
+7 −1 CONTRIBUTING.md
+2 −0 bench/rollup_config_benchmarks.js
+0 −68 build/flow-remove-types.js
+1 −3 build/rollup_plugins.js
+1 −1 build/run-node
+1 −1 build/run-tap
+0 −10 debug/markers.html
+4 −5 package.json
+10 −2 rollup.config.js
+19 −27 src/data/bucket.js
+2 −11 src/data/dem_data.js
+2 −10 src/data/program_configuration.js
+30 −65 src/gl/value.js
+48 −51 src/render/glyph_atlas.js
+64 −71 src/render/image_atlas.js
+2 −3 src/render/image_manager.js
+1 −1 src/render/painter.js
+1 −1 src/render/program.js
+4 −1 src/shaders/collision_box.vertex.glsl
+4 −4 src/shaders/index.js
+4 −1 src/shaders/symbol_icon.vertex.glsl
+4 −1 src/shaders/symbol_sdf.vertex.glsl
+1 −1 src/source/raster_dem_tile_worker_source.js
+1 −1 src/source/tile.js
+3 −12 src/source/tile_id.js
+1 −1 src/source/worker_source.js
+4 −4 src/source/worker_tile.js
+9 −24 src/style-spec/expression/index.js
+1 −8 src/style-spec/expression/stops.js
+11 −28 src/style-spec/expression/types.js
+4 −12 src/style-spec/expression/values.js
+2 −10 src/style-spec/function/index.js
+18 −6 src/style-spec/style-spec.js
+2 −10 src/style-spec/util/result.js
+11 −28 src/style/properties.js
+3 −12 src/style/query_utils.js
+3 −18 src/symbol/quads.js
+1 −8 src/symbol/symbol_layout.js
+32 −0 src/ui/anchor.js
+4 −5 src/ui/bind_handlers.js
+48 −54 src/ui/camera.js
+6 −3 src/ui/control/attribution_control.js
+12 −4 src/ui/control/geolocate_control.js
+8 −4 src/ui/control/navigation_control.js
+12 −6 src/ui/control/scale_control.js
+3 −12 src/ui/events.js
+13 −4 src/ui/handler/drag_pan.js
+13 −3 src/ui/handler/drag_rotate.js
+32 −14 src/ui/handler/scroll_zoom.js
+16 −6 src/ui/handler/touch_zoom_rotate.js
+27 −6 src/ui/map.js
+34 −25 src/ui/marker.js
+19 −33 src/ui/popup.js
+3 −12 src/util/evented.js
+2 −10 src/util/image.js
+68 −0 src/util/task_queue.js
+3 −12 src/util/web_worker_transfer.js
+1 −1 test/expression.test.js
+3 −4 test/node_modules/mapbox-gl-js-test.js
+1 −1 test/query.test.js
+1 −1 test/render.test.js
+1 −1 test/unit/data/dem_data.test.js
+1 −1 test/unit/source/raster_dem_tile_worker_source.test.js
+2 −2 test/unit/symbol/quads.test.js
+50 −40 test/unit/ui/camera.test.js
+9 −9 test/unit/ui/handler/box_zoom.test.js
+62 −59 test/unit/ui/handler/drag_pan.test.js
+56 −52 test/unit/ui/handler/drag_rotate.test.js
+11 −11 test/unit/ui/handler/scroll_zoom.test.js
+11 −11 test/unit/ui/handler/touch_zoom_rotate.test.js
+46 −0 test/unit/ui/map.test.js
+13 −13 test/unit/ui/map/isMoving.test.js
+3 −3 test/unit/ui/map/isRotating.test.js
+4 −4 test/unit/ui/map/isZooming.test.js
+47 −0 test/unit/ui/map/requestRenderFrame.test.js
+134 −104 test/unit/ui/marker.test.js
+122 −0 test/unit/util/task_queue.test.js
+128 −21 yarn.lock
5 changes: 4 additions & 1 deletion src/mbgl/shaders/collision_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/mbgl/shaders/symbol_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/mbgl/shaders/symbol_sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0a15448

Please sign in to comment.