@mapwhit/tilerenderer 0.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/LICENSE.txt +87 -0
  2. package/README.md +25 -0
  3. package/build/min/.dir +0 -0
  4. package/build/min/package.json +3 -0
  5. package/build/min/src/shaders/_prelude.fragment.glsl.txt +13 -0
  6. package/build/min/src/shaders/_prelude.vertex.glsl.txt +14 -0
  7. package/build/min/src/shaders/background.fragment.glsl.txt +5 -0
  8. package/build/min/src/shaders/background.vertex.glsl.txt +1 -0
  9. package/build/min/src/shaders/background_pattern.fragment.glsl.txt +5 -0
  10. package/build/min/src/shaders/background_pattern.vertex.glsl.txt +1 -0
  11. package/build/min/src/shaders/circle.fragment.glsl.txt +20 -0
  12. package/build/min/src/shaders/circle.vertex.glsl.txt +17 -0
  13. package/build/min/src/shaders/clipping_mask.fragment.glsl.txt +1 -0
  14. package/build/min/src/shaders/clipping_mask.vertex.glsl.txt +1 -0
  15. package/build/min/src/shaders/collision_box.fragment.glsl.txt +1 -0
  16. package/build/min/src/shaders/collision_box.vertex.glsl.txt +1 -0
  17. package/build/min/src/shaders/collision_circle.fragment.glsl.txt +1 -0
  18. package/build/min/src/shaders/collision_circle.vertex.glsl.txt +1 -0
  19. package/build/min/src/shaders/debug.fragment.glsl.txt +1 -0
  20. package/build/min/src/shaders/debug.vertex.glsl.txt +1 -0
  21. package/build/min/src/shaders/fill.fragment.glsl.txt +10 -0
  22. package/build/min/src/shaders/fill.vertex.glsl.txt +7 -0
  23. package/build/min/src/shaders/fill_extrusion.fragment.glsl.txt +13 -0
  24. package/build/min/src/shaders/fill_extrusion.vertex.glsl.txt +9 -0
  25. package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.txt +15 -0
  26. package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.txt +11 -0
  27. package/build/min/src/shaders/fill_outline.fragment.glsl.txt +10 -0
  28. package/build/min/src/shaders/fill_outline.vertex.glsl.txt +7 -0
  29. package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.txt +13 -0
  30. package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.txt +9 -0
  31. package/build/min/src/shaders/fill_pattern.fragment.glsl.txt +13 -0
  32. package/build/min/src/shaders/fill_pattern.vertex.glsl.txt +9 -0
  33. package/build/min/src/shaders/heatmap.fragment.glsl.txt +10 -0
  34. package/build/min/src/shaders/heatmap.vertex.glsl.txt +8 -0
  35. package/build/min/src/shaders/heatmap_texture.fragment.glsl.txt +5 -0
  36. package/build/min/src/shaders/heatmap_texture.vertex.glsl.txt +1 -0
  37. package/build/min/src/shaders/hillshade.fragment.glsl.txt +7 -0
  38. package/build/min/src/shaders/hillshade.vertex.glsl.txt +1 -0
  39. package/build/min/src/shaders/hillshade_prepare.fragment.glsl.txt +8 -0
  40. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.txt +1 -0
  41. package/build/min/src/shaders/line.fragment.glsl.txt +12 -0
  42. package/build/min/src/shaders/line.vertex.glsl.txt +17 -0
  43. package/build/min/src/shaders/line_gradient.fragment.glsl.txt +10 -0
  44. package/build/min/src/shaders/line_gradient.vertex.glsl.txt +16 -0
  45. package/build/min/src/shaders/line_pattern.fragment.glsl.txt +15 -0
  46. package/build/min/src/shaders/line_pattern.vertex.glsl.txt +20 -0
  47. package/build/min/src/shaders/line_sdf.fragment.glsl.txt +17 -0
  48. package/build/min/src/shaders/line_sdf.vertex.glsl.txt +20 -0
  49. package/build/min/src/shaders/raster.fragment.glsl.txt +5 -0
  50. package/build/min/src/shaders/raster.vertex.glsl.txt +1 -0
  51. package/build/min/src/shaders/symbol_icon.fragment.glsl.txt +9 -0
  52. package/build/min/src/shaders/symbol_icon.vertex.glsl.txt +5 -0
  53. package/build/min/src/shaders/symbol_sdf.fragment.glsl.txt +19 -0
  54. package/build/min/src/shaders/symbol_sdf.vertex.glsl.txt +13 -0
  55. package/package.json +44 -0
  56. package/src/css/mapbox-gl.css +506 -0
  57. package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
  58. package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
  59. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
  60. package/src/css/svg/mapboxgl-ctrl-geolocate-background.svg +3 -0
  61. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +3 -0
  62. package/src/css/svg/mapboxgl-ctrl-logo-compact.svg +2 -0
  63. package/src/css/svg/mapboxgl-ctrl-logo.svg +1 -0
  64. package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
  65. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
  66. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
  67. package/src/data/array_types.js +1138 -0
  68. package/src/data/bucket/circle_attributes.js +5 -0
  69. package/src/data/bucket/circle_bucket.js +118 -0
  70. package/src/data/bucket/fill_attributes.js +5 -0
  71. package/src/data/bucket/fill_bucket.js +166 -0
  72. package/src/data/bucket/fill_extrusion_attributes.js +11 -0
  73. package/src/data/bucket/fill_extrusion_bucket.js +247 -0
  74. package/src/data/bucket/heatmap_bucket.js +12 -0
  75. package/src/data/bucket/line_attributes.js +11 -0
  76. package/src/data/bucket/line_bucket.js +625 -0
  77. package/src/data/bucket/pattern_attributes.js +9 -0
  78. package/src/data/bucket/pattern_bucket_features.js +44 -0
  79. package/src/data/bucket/symbol_attributes.js +95 -0
  80. package/src/data/bucket/symbol_bucket.js +697 -0
  81. package/src/data/bucket.js +53 -0
  82. package/src/data/dem_data.js +126 -0
  83. package/src/data/extent.js +17 -0
  84. package/src/data/feature_index.js +254 -0
  85. package/src/data/index_array_type.js +14 -0
  86. package/src/data/load_geometry.js +42 -0
  87. package/src/data/pos_attributes.js +3 -0
  88. package/src/data/program_configuration.js +782 -0
  89. package/src/data/raster_bounds_attributes.js +6 -0
  90. package/src/data/segment.js +63 -0
  91. package/src/geo/coordinate.js +78 -0
  92. package/src/geo/lng_lat.js +129 -0
  93. package/src/geo/lng_lat_bounds.js +253 -0
  94. package/src/geo/transform.js +605 -0
  95. package/src/gl/color_mode.js +21 -0
  96. package/src/gl/context.js +193 -0
  97. package/src/gl/cull_face_mode.js +22 -0
  98. package/src/gl/depth_mode.js +18 -0
  99. package/src/gl/framebuffer.js +28 -0
  100. package/src/gl/index_buffer.js +52 -0
  101. package/src/gl/stencil_mode.js +17 -0
  102. package/src/gl/types.js +0 -0
  103. package/src/gl/value.js +676 -0
  104. package/src/gl/vertex_buffer.js +101 -0
  105. package/src/index.js +50 -0
  106. package/src/render/draw_background.js +60 -0
  107. package/src/render/draw_circle.js +55 -0
  108. package/src/render/draw_collision_debug.js +45 -0
  109. package/src/render/draw_debug.js +429 -0
  110. package/src/render/draw_fill.js +143 -0
  111. package/src/render/draw_fill_extrusion.js +101 -0
  112. package/src/render/draw_heatmap.js +159 -0
  113. package/src/render/draw_hillshade.js +144 -0
  114. package/src/render/draw_line.js +99 -0
  115. package/src/render/draw_raster.js +151 -0
  116. package/src/render/draw_symbol.js +231 -0
  117. package/src/render/glyph_atlas.js +55 -0
  118. package/src/render/glyph_manager.js +145 -0
  119. package/src/render/image_atlas.js +97 -0
  120. package/src/render/image_manager.js +183 -0
  121. package/src/render/line_atlas.js +139 -0
  122. package/src/render/painter.js +483 -0
  123. package/src/render/program/background_program.js +46 -0
  124. package/src/render/program/circle_program.js +40 -0
  125. package/src/render/program/clipping_mask_program.js +11 -0
  126. package/src/render/program/collision_program.js +28 -0
  127. package/src/render/program/debug_program.js +13 -0
  128. package/src/render/program/fill_extrusion_program.js +76 -0
  129. package/src/render/program/fill_program.js +60 -0
  130. package/src/render/program/heatmap_program.js +46 -0
  131. package/src/render/program/hillshade_program.js +77 -0
  132. package/src/render/program/line_program.js +119 -0
  133. package/src/render/program/pattern.js +57 -0
  134. package/src/render/program/program_uniforms.js +46 -0
  135. package/src/render/program/raster_program.js +50 -0
  136. package/src/render/program/symbol_program.js +112 -0
  137. package/src/render/program.js +133 -0
  138. package/src/render/texture.js +88 -0
  139. package/src/render/tile_mask.js +108 -0
  140. package/src/render/uniform_binding.js +129 -0
  141. package/src/render/vertex_array_object.js +155 -0
  142. package/src/shaders/README.md +42 -0
  143. package/src/shaders/_prelude.fragment.glsl +17 -0
  144. package/src/shaders/_prelude.vertex.glsl +73 -0
  145. package/src/shaders/background.fragment.glsl +10 -0
  146. package/src/shaders/background.vertex.glsl +7 -0
  147. package/src/shaders/background_pattern.fragment.glsl +28 -0
  148. package/src/shaders/background_pattern.vertex.glsl +20 -0
  149. package/src/shaders/circle.fragment.glsl +39 -0
  150. package/src/shaders/circle.vertex.glsl +63 -0
  151. package/src/shaders/clipping_mask.fragment.glsl +3 -0
  152. package/src/shaders/clipping_mask.vertex.glsl +7 -0
  153. package/src/shaders/collision_box.fragment.glsl +21 -0
  154. package/src/shaders/collision_box.vertex.glsl +26 -0
  155. package/src/shaders/collision_circle.fragment.glsl +34 -0
  156. package/src/shaders/collision_circle.vertex.glsl +36 -0
  157. package/src/shaders/debug.fragment.glsl +5 -0
  158. package/src/shaders/debug.vertex.glsl +7 -0
  159. package/src/shaders/encode_attribute.js +19 -0
  160. package/src/shaders/fill.fragment.glsl +13 -0
  161. package/src/shaders/fill.vertex.glsl +13 -0
  162. package/src/shaders/fill_extrusion.fragment.glsl +16 -0
  163. package/src/shaders/fill_extrusion.vertex.glsl +66 -0
  164. package/src/shaders/fill_extrusion_pattern.fragment.glsl +41 -0
  165. package/src/shaders/fill_extrusion_pattern.vertex.glsl +76 -0
  166. package/src/shaders/fill_outline.fragment.glsl +17 -0
  167. package/src/shaders/fill_outline.vertex.glsl +17 -0
  168. package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
  169. package/src/shaders/fill_outline_pattern.vertex.glsl +41 -0
  170. package/src/shaders/fill_pattern.fragment.glsl +36 -0
  171. package/src/shaders/fill_pattern.vertex.glsl +36 -0
  172. package/src/shaders/heatmap.fragment.glsl +21 -0
  173. package/src/shaders/heatmap.vertex.glsl +53 -0
  174. package/src/shaders/heatmap_texture.fragment.glsl +14 -0
  175. package/src/shaders/heatmap_texture.vertex.glsl +11 -0
  176. package/src/shaders/hillshade.fragment.glsl +52 -0
  177. package/src/shaders/hillshade.vertex.glsl +11 -0
  178. package/src/shaders/hillshade_prepare.fragment.glsl +72 -0
  179. package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
  180. package/src/shaders/index.js +194 -0
  181. package/src/shaders/line.fragment.glsl +28 -0
  182. package/src/shaders/line.vertex.glsl +84 -0
  183. package/src/shaders/line_gradient.fragment.glsl +34 -0
  184. package/src/shaders/line_gradient.vertex.glsl +84 -0
  185. package/src/shaders/line_pattern.fragment.glsl +69 -0
  186. package/src/shaders/line_pattern.vertex.glsl +88 -0
  187. package/src/shaders/line_sdf.fragment.glsl +44 -0
  188. package/src/shaders/line_sdf.vertex.glsl +95 -0
  189. package/src/shaders/raster.fragment.glsl +52 -0
  190. package/src/shaders/raster.vertex.glsl +21 -0
  191. package/src/shaders/symbol_icon.fragment.glsl +17 -0
  192. package/src/shaders/symbol_icon.vertex.glsl +91 -0
  193. package/src/shaders/symbol_sdf.fragment.glsl +50 -0
  194. package/src/shaders/symbol_sdf.vertex.glsl +117 -0
  195. package/src/source/geojson_source.js +267 -0
  196. package/src/source/geojson_worker_source.js +210 -0
  197. package/src/source/geojson_wrapper.js +67 -0
  198. package/src/source/image_source.js +213 -0
  199. package/src/source/load_tilejson.js +40 -0
  200. package/src/source/pixels_to_tile_units.js +17 -0
  201. package/src/source/query_features.js +198 -0
  202. package/src/source/raster_dem_tile_source.js +140 -0
  203. package/src/source/raster_dem_tile_worker_source.js +26 -0
  204. package/src/source/raster_tile_source.js +126 -0
  205. package/src/source/rtl_text_plugin.js +63 -0
  206. package/src/source/source.js +75 -0
  207. package/src/source/source_cache.js +794 -0
  208. package/src/source/source_state.js +55 -0
  209. package/src/source/tile.js +332 -0
  210. package/src/source/tile_bounds.js +40 -0
  211. package/src/source/tile_cache.js +122 -0
  212. package/src/source/tile_id.js +150 -0
  213. package/src/source/vector_tile_source.js +144 -0
  214. package/src/source/vector_tile_worker_source.js +126 -0
  215. package/src/source/worker.js +175 -0
  216. package/src/source/worker_source.js +14 -0
  217. package/src/source/worker_tile.js +199 -0
  218. package/src/style/create_style_layer.js +25 -0
  219. package/src/style/evaluation_parameters.js +45 -0
  220. package/src/style/light.js +112 -0
  221. package/src/style/load_glyph_range.js +17 -0
  222. package/src/style/load_sprite.js +26 -0
  223. package/src/style/parse_glyph_pbf.js +45 -0
  224. package/src/style/pauseable_placement.js +88 -0
  225. package/src/style/properties.js +691 -0
  226. package/src/style/query_utils.js +39 -0
  227. package/src/style/style.js +955 -0
  228. package/src/style/style_layer/background_style_layer.js +11 -0
  229. package/src/style/style_layer/background_style_layer_properties.js +25 -0
  230. package/src/style/style_layer/circle_style_layer.js +93 -0
  231. package/src/style/style_layer/circle_style_layer_properties.js +76 -0
  232. package/src/style/style_layer/fill_extrusion_style_layer.js +194 -0
  233. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +56 -0
  234. package/src/style/style_layer/fill_style_layer.js +46 -0
  235. package/src/style/style_layer/fill_style_layer_properties.js +45 -0
  236. package/src/style/style_layer/heatmap_style_layer.js +51 -0
  237. package/src/style/style_layer/heatmap_style_layer_properties.js +52 -0
  238. package/src/style/style_layer/hillshade_style_layer.js +15 -0
  239. package/src/style/style_layer/hillshade_style_layer_properties.js +43 -0
  240. package/src/style/style_layer/line_style_layer.js +129 -0
  241. package/src/style/style_layer/line_style_layer_properties.js +104 -0
  242. package/src/style/style_layer/raster_style_layer.js +11 -0
  243. package/src/style/style_layer/raster_style_layer_properties.js +55 -0
  244. package/src/style/style_layer/symbol_style_layer.js +66 -0
  245. package/src/style/style_layer/symbol_style_layer_properties.js +288 -0
  246. package/src/style/style_layer.js +183 -0
  247. package/src/style/style_layer_index.js +61 -0
  248. package/src/style/zoom_history.js +36 -0
  249. package/src/style-spec/deref.js +51 -0
  250. package/src/style-spec/error/parsing_error.js +8 -0
  251. package/src/style-spec/error/validation_error.js +10 -0
  252. package/src/style-spec/expression/compound_expression.js +118 -0
  253. package/src/style-spec/expression/definitions/array.js +82 -0
  254. package/src/style-spec/expression/definitions/assertion.js +69 -0
  255. package/src/style-spec/expression/definitions/at.js +57 -0
  256. package/src/style-spec/expression/definitions/case.js +73 -0
  257. package/src/style-spec/expression/definitions/coalesce.js +68 -0
  258. package/src/style-spec/expression/definitions/coercion.js +96 -0
  259. package/src/style-spec/expression/definitions/collator.js +102 -0
  260. package/src/style-spec/expression/definitions/equals.js +93 -0
  261. package/src/style-spec/expression/definitions/index.js +407 -0
  262. package/src/style-spec/expression/definitions/interpolate.js +235 -0
  263. package/src/style-spec/expression/definitions/length.js +54 -0
  264. package/src/style-spec/expression/definitions/let.js +60 -0
  265. package/src/style-spec/expression/definitions/literal.js +64 -0
  266. package/src/style-spec/expression/definitions/match.js +142 -0
  267. package/src/style-spec/expression/definitions/step.js +116 -0
  268. package/src/style-spec/expression/definitions/var.js +38 -0
  269. package/src/style-spec/expression/evaluation_context.js +35 -0
  270. package/src/style-spec/expression/index.js +329 -0
  271. package/src/style-spec/expression/is_constant.js +63 -0
  272. package/src/style-spec/expression/parsing_context.js +213 -0
  273. package/src/style-spec/expression/parsing_error.js +9 -0
  274. package/src/style-spec/expression/runtime_error.js +12 -0
  275. package/src/style-spec/expression/scope.js +34 -0
  276. package/src/style-spec/expression/stops.js +37 -0
  277. package/src/style-spec/expression/types.js +77 -0
  278. package/src/style-spec/expression/values.js +126 -0
  279. package/src/style-spec/feature_filter/README.md +55 -0
  280. package/src/style-spec/feature_filter/index.js +158 -0
  281. package/src/style-spec/function/convert.js +256 -0
  282. package/src/style-spec/function/index.js +299 -0
  283. package/src/style-spec/group_by_layout.js +68 -0
  284. package/src/style-spec/reference/v8.json +5356 -0
  285. package/src/style-spec/util/color.js +73 -0
  286. package/src/style-spec/util/color_spaces.js +128 -0
  287. package/src/style-spec/util/eval_support.js +8 -0
  288. package/src/style-spec/util/get_type.js +18 -0
  289. package/src/style-spec/util/interpolate.js +21 -0
  290. package/src/style-spec/util/properties.js +17 -0
  291. package/src/style-spec/util/ref_properties.js +1 -0
  292. package/src/style-spec/util/result.js +19 -0
  293. package/src/symbol/anchor.js +21 -0
  294. package/src/symbol/check_max_angle.js +75 -0
  295. package/src/symbol/clip_line.js +73 -0
  296. package/src/symbol/collision_feature.js +230 -0
  297. package/src/symbol/collision_index.js +379 -0
  298. package/src/symbol/cross_tile_symbol_index.js +270 -0
  299. package/src/symbol/get_anchors.js +177 -0
  300. package/src/symbol/grid_index.js +318 -0
  301. package/src/symbol/mergelines.js +75 -0
  302. package/src/symbol/opacity_state.js +21 -0
  303. package/src/symbol/placement.js +563 -0
  304. package/src/symbol/projection.js +601 -0
  305. package/src/symbol/quads.js +173 -0
  306. package/src/symbol/shaping.js +347 -0
  307. package/src/symbol/symbol_layout.js +519 -0
  308. package/src/symbol/symbol_size.js +110 -0
  309. package/src/symbol/transform_text.js +16 -0
  310. package/src/ui/anchor.js +24 -0
  311. package/src/ui/bind_handlers.js +199 -0
  312. package/src/ui/camera.js +954 -0
  313. package/src/ui/events.js +210 -0
  314. package/src/ui/handler/box_zoom.js +151 -0
  315. package/src/ui/handler/dblclick_zoom.js +91 -0
  316. package/src/ui/handler/drag_pan.js +285 -0
  317. package/src/ui/handler/drag_rotate.js +290 -0
  318. package/src/ui/handler/frame.js +28 -0
  319. package/src/ui/handler/inertia.js +45 -0
  320. package/src/ui/handler/keyboard.js +148 -0
  321. package/src/ui/handler/scroll_zoom.js +284 -0
  322. package/src/ui/handler/touch_zoom_rotate.js +263 -0
  323. package/src/ui/map.js +1645 -0
  324. package/src/util/actor.js +104 -0
  325. package/src/util/async.js +23 -0
  326. package/src/util/browser.js +61 -0
  327. package/src/util/callback.js +26 -0
  328. package/src/util/classify_rings.js +43 -0
  329. package/src/util/color_ramp.js +24 -0
  330. package/src/util/config.js +24 -0
  331. package/src/util/dictionary_coder.js +25 -0
  332. package/src/util/dispatcher.js +68 -0
  333. package/src/util/dom.js +102 -0
  334. package/src/util/evented.js +182 -0
  335. package/src/util/find_pole_of_inaccessibility.js +129 -0
  336. package/src/util/global_worker_pool.js +15 -0
  337. package/src/util/image.js +124 -0
  338. package/src/util/interpolate.js +5 -0
  339. package/src/util/intersection_tests.js +207 -0
  340. package/src/util/is_char_in_unicode_block.js +287 -0
  341. package/src/util/loader/image.js +32 -0
  342. package/src/util/object.js +178 -0
  343. package/src/util/script_detection.js +337 -0
  344. package/src/util/struct_array.js +197 -0
  345. package/src/util/task_queue.js +57 -0
  346. package/src/util/throttle.js +26 -0
  347. package/src/util/tile_cover.js +114 -0
  348. package/src/util/token.js +13 -0
  349. package/src/util/unique_id.js +12 -0
  350. package/src/util/util.js +192 -0
  351. package/src/util/vectortile_to_geojson.js +44 -0
  352. package/src/util/verticalize_punctuation.js +112 -0
  353. package/src/util/warn.js +21 -0
  354. package/src/util/web_worker.js +5 -0
  355. package/src/util/web_worker_transfer.js +228 -0
  356. package/src/util/worker_pool.js +41 -0
@@ -0,0 +1,95 @@
1
+ // floor(127 / 2) == 63.0
2
+ // the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
3
+ // stored in a byte (-128..127). we scale regular normals up to length 63, but
4
+ // there are also "special" normals that have a bigger length (of up to 126 in
5
+ // this case).
6
+ // #define scale 63.0
7
+ #define scale 0.015873016
8
+
9
+ // We scale the distance before adding it to the buffers so that we can store
10
+ // long distances for long segments. Use this value to unscale the distance.
11
+ #define LINE_DISTANCE_SCALE 2.0
12
+
13
+ // the distance over which the line edge fades out.
14
+ // Retina devices need a smaller distance to avoid aliasing.
15
+ #define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0
16
+
17
+ attribute vec4 a_pos_normal;
18
+ attribute vec4 a_data;
19
+
20
+ uniform mat4 u_matrix;
21
+ uniform mediump float u_ratio;
22
+ uniform vec2 u_patternscale_a;
23
+ uniform float u_tex_y_a;
24
+ uniform vec2 u_patternscale_b;
25
+ uniform float u_tex_y_b;
26
+ uniform vec2 u_gl_units_to_pixels;
27
+
28
+ varying vec2 v_normal;
29
+ varying vec2 v_width2;
30
+ varying vec2 v_tex_a;
31
+ varying vec2 v_tex_b;
32
+ varying float v_gamma_scale;
33
+
34
+ #pragma mapbox: define highp vec4 color
35
+ #pragma mapbox: define lowp float blur
36
+ #pragma mapbox: define lowp float opacity
37
+ #pragma mapbox: define mediump float gapwidth
38
+ #pragma mapbox: define lowp float offset
39
+ #pragma mapbox: define mediump float width
40
+ #pragma mapbox: define lowp float floorwidth
41
+
42
+ void main() {
43
+ #pragma mapbox: initialize highp vec4 color
44
+ #pragma mapbox: initialize lowp float blur
45
+ #pragma mapbox: initialize lowp float opacity
46
+ #pragma mapbox: initialize mediump float gapwidth
47
+ #pragma mapbox: initialize lowp float offset
48
+ #pragma mapbox: initialize mediump float width
49
+ #pragma mapbox: initialize lowp float floorwidth
50
+
51
+ vec2 a_extrude = a_data.xy - 128.0;
52
+ float a_direction = mod(a_data.z, 4.0) - 1.0;
53
+ float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
54
+
55
+ vec2 pos = a_pos_normal.xy;
56
+
57
+ // x is 1 if it's a round cap, 0 otherwise
58
+ // y is 1 if the normal points up, and -1 if it points down
59
+ mediump vec2 normal = a_pos_normal.zw;
60
+ v_normal = normal;
61
+
62
+ // these transformations used to be applied in the JS and native code bases.
63
+ // moved them into the shader for clarity and simplicity.
64
+ gapwidth = gapwidth / 2.0;
65
+ float halfwidth = width / 2.0;
66
+ offset = -1.0 * offset;
67
+
68
+ float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
69
+ float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
70
+
71
+ // Scale the extrusion vector down to a normal and then up by the line width
72
+ // of this vertex.
73
+ mediump vec2 dist =outset * a_extrude * scale;
74
+
75
+ // Calculate the offset when drawing a line that is to the side of the actual line.
76
+ // We do this by creating a vector that points towards the extrude, but rotate
77
+ // it when we're drawing round end points (a_direction = -1 or 1) since their
78
+ // extrude vector points in another direction.
79
+ mediump float u = 0.5 * a_direction;
80
+ mediump float t = 1.0 - abs(u);
81
+ mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
82
+
83
+ vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
84
+ gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
85
+
86
+ // calculate how much the perspective view squishes or stretches the extrude
87
+ float extrude_length_without_perspective = length(dist);
88
+ float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);
89
+ v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
90
+
91
+ v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a);
92
+ v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b);
93
+
94
+ v_width2 = vec2(outset, inset);
95
+ }
@@ -0,0 +1,52 @@
1
+ uniform float u_fade_t;
2
+ uniform float u_opacity;
3
+ uniform sampler2D u_image0;
4
+ uniform sampler2D u_image1;
5
+ varying vec2 v_pos0;
6
+ varying vec2 v_pos1;
7
+
8
+ uniform float u_brightness_low;
9
+ uniform float u_brightness_high;
10
+
11
+ uniform float u_saturation_factor;
12
+ uniform float u_contrast_factor;
13
+ uniform vec3 u_spin_weights;
14
+
15
+ void main() {
16
+
17
+ // read and cross-fade colors from the main and parent tiles
18
+ vec4 color0 = texture2D(u_image0, v_pos0);
19
+ vec4 color1 = texture2D(u_image1, v_pos1);
20
+ if (color0.a > 0.0) {
21
+ color0.rgb = color0.rgb / color0.a;
22
+ }
23
+ if (color1.a > 0.0) {
24
+ color1.rgb = color1.rgb / color1.a;
25
+ }
26
+ vec4 color = mix(color0, color1, u_fade_t);
27
+ color.a *= u_opacity;
28
+ vec3 rgb = color.rgb;
29
+
30
+ // spin
31
+ rgb = vec3(
32
+ dot(rgb, u_spin_weights.xyz),
33
+ dot(rgb, u_spin_weights.zxy),
34
+ dot(rgb, u_spin_weights.yzx));
35
+
36
+ // saturation
37
+ float average = (color.r + color.g + color.b) / 3.0;
38
+ rgb += (average - rgb) * u_saturation_factor;
39
+
40
+ // contrast
41
+ rgb = (rgb - 0.5) * u_contrast_factor + 0.5;
42
+
43
+ // brightness
44
+ vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);
45
+ vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);
46
+
47
+ gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a);
48
+
49
+ #ifdef OVERDRAW_INSPECTOR
50
+ gl_FragColor = vec4(1.0);
51
+ #endif
52
+ }
@@ -0,0 +1,21 @@
1
+ uniform mat4 u_matrix;
2
+ uniform vec2 u_tl_parent;
3
+ uniform float u_scale_parent;
4
+ uniform float u_buffer_scale;
5
+
6
+ attribute vec2 a_pos;
7
+ attribute vec2 a_texture_pos;
8
+
9
+ varying vec2 v_pos0;
10
+ varying vec2 v_pos1;
11
+
12
+ void main() {
13
+ gl_Position = u_matrix * vec4(a_pos, 0, 1);
14
+ // We are using Int16 for texture position coordinates to give us enough precision for
15
+ // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer
16
+ // as an arbitrarily high number to preserve adequate precision when rendering.
17
+ // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,
18
+ // so math for modifying either is consistent.
19
+ v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;
20
+ v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;
21
+ }
@@ -0,0 +1,17 @@
1
+ uniform sampler2D u_texture;
2
+
3
+ #pragma mapbox: define lowp float opacity
4
+
5
+ varying vec2 v_tex;
6
+ varying float v_fade_opacity;
7
+
8
+ void main() {
9
+ #pragma mapbox: initialize lowp float opacity
10
+
11
+ lowp float alpha = opacity * v_fade_opacity;
12
+ gl_FragColor = texture2D(u_texture, v_tex) * alpha;
13
+
14
+ #ifdef OVERDRAW_INSPECTOR
15
+ gl_FragColor = vec4(1.0);
16
+ #endif
17
+ }
@@ -0,0 +1,91 @@
1
+ const float PI = 3.141592653589793;
2
+
3
+ attribute vec4 a_pos_offset;
4
+ attribute vec4 a_data;
5
+ attribute vec3 a_projected_pos;
6
+ attribute float a_fade_opacity;
7
+
8
+ uniform bool u_is_size_zoom_constant;
9
+ uniform bool u_is_size_feature_constant;
10
+ uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
11
+ uniform highp float u_size; // used when size is both zoom and feature constant
12
+ uniform highp float u_camera_to_center_distance;
13
+ uniform highp float u_pitch;
14
+ uniform bool u_rotate_symbol;
15
+ uniform highp float u_aspect_ratio;
16
+ uniform float u_fade_change;
17
+
18
+ #pragma mapbox: define lowp float opacity
19
+
20
+ uniform mat4 u_matrix;
21
+ uniform mat4 u_label_plane_matrix;
22
+ uniform mat4 u_gl_coord_matrix;
23
+
24
+ uniform bool u_is_text;
25
+ uniform bool u_pitch_with_map;
26
+
27
+ uniform vec2 u_texsize;
28
+
29
+ varying vec2 v_tex;
30
+ varying float v_fade_opacity;
31
+
32
+ void main() {
33
+ #pragma mapbox: initialize lowp float opacity
34
+
35
+ vec2 a_pos = a_pos_offset.xy;
36
+ vec2 a_offset = a_pos_offset.zw;
37
+
38
+ vec2 a_tex = a_data.xy;
39
+ vec2 a_size = a_data.zw;
40
+
41
+ highp float segment_angle = -a_projected_pos[2];
42
+
43
+ float size;
44
+ if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
45
+ size = mix(a_size[0], a_size[1], u_size_t) / 10.0;
46
+ } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
47
+ size = a_size[0] / 10.0;
48
+ } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {
49
+ size = u_size;
50
+ } else {
51
+ size = u_size;
52
+ }
53
+
54
+ vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);
55
+ highp float camera_to_anchor_distance = projectedPoint.w;
56
+ // See comments in symbol_sdf.vertex
57
+ highp float distance_ratio = u_pitch_with_map ?
58
+ camera_to_anchor_distance / u_camera_to_center_distance :
59
+ u_camera_to_center_distance / camera_to_anchor_distance;
60
+ highp float perspective_ratio = clamp(
61
+ 0.5 + 0.5 * distance_ratio,
62
+ 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
63
+ 4.0);
64
+
65
+ size *= perspective_ratio;
66
+
67
+ float fontScale = u_is_text ? size / 24.0 : size;
68
+
69
+ highp float symbol_rotation = 0.0;
70
+ if (u_rotate_symbol) {
71
+ // See comments in symbol_sdf.vertex
72
+ vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);
73
+
74
+ vec2 a = projectedPoint.xy / projectedPoint.w;
75
+ vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
76
+
77
+ symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
78
+ }
79
+
80
+ highp float angle_sin = sin(segment_angle + symbol_rotation);
81
+ highp float angle_cos = cos(segment_angle + symbol_rotation);
82
+ mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
83
+
84
+ vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
85
+ gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);
86
+
87
+ v_tex = a_tex / u_texsize;
88
+ vec2 fade_opacity = unpack_opacity(a_fade_opacity);
89
+ float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
90
+ v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
91
+ }
@@ -0,0 +1,50 @@
1
+ #define SDF_PX 8.0
2
+ #define EDGE_GAMMA 0.105/DEVICE_PIXEL_RATIO
3
+
4
+ uniform bool u_is_halo;
5
+ #pragma mapbox: define highp vec4 fill_color
6
+ #pragma mapbox: define highp vec4 halo_color
7
+ #pragma mapbox: define lowp float opacity
8
+ #pragma mapbox: define lowp float halo_width
9
+ #pragma mapbox: define lowp float halo_blur
10
+
11
+ uniform sampler2D u_texture;
12
+ uniform highp float u_gamma_scale;
13
+ uniform bool u_is_text;
14
+
15
+ varying vec2 v_data0;
16
+ varying vec3 v_data1;
17
+
18
+ void main() {
19
+ #pragma mapbox: initialize highp vec4 fill_color
20
+ #pragma mapbox: initialize highp vec4 halo_color
21
+ #pragma mapbox: initialize lowp float opacity
22
+ #pragma mapbox: initialize lowp float halo_width
23
+ #pragma mapbox: initialize lowp float halo_blur
24
+
25
+ vec2 tex = v_data0.xy;
26
+ float gamma_scale = v_data1.x;
27
+ float size = v_data1.y;
28
+ float fade_opacity = v_data1[2];
29
+
30
+ float fontScale = u_is_text ? size / 24.0 : size;
31
+
32
+ lowp vec4 color = fill_color;
33
+ highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
34
+ lowp float buff = (256.0 - 64.0) / 256.0;
35
+ if (u_is_halo) {
36
+ color = halo_color;
37
+ gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
38
+ buff = (6.0 - halo_width / fontScale) / SDF_PX;
39
+ }
40
+
41
+ lowp float dist = texture2D(u_texture, tex).a;
42
+ highp float gamma_scaled = gamma * gamma_scale;
43
+ highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
44
+
45
+ gl_FragColor = color * (alpha * opacity * fade_opacity);
46
+
47
+ #ifdef OVERDRAW_INSPECTOR
48
+ gl_FragColor = vec4(1.0);
49
+ #endif
50
+ }
@@ -0,0 +1,117 @@
1
+ const float PI = 3.141592653589793;
2
+
3
+ attribute vec4 a_pos_offset;
4
+ attribute vec4 a_data;
5
+ attribute vec3 a_projected_pos;
6
+ attribute float a_fade_opacity;
7
+
8
+ // contents of a_size vary based on the type of property value
9
+ // used for {text,icon}-size.
10
+ // For constants, a_size is disabled.
11
+ // For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.
12
+ // For composite functions:
13
+ // [ text-size(lowerZoomStop, feature),
14
+ // text-size(upperZoomStop, feature) ]
15
+ uniform bool u_is_size_zoom_constant;
16
+ uniform bool u_is_size_feature_constant;
17
+ uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
18
+ uniform highp float u_size; // used when size is both zoom and feature constant
19
+
20
+ #pragma mapbox: define highp vec4 fill_color
21
+ #pragma mapbox: define highp vec4 halo_color
22
+ #pragma mapbox: define lowp float opacity
23
+ #pragma mapbox: define lowp float halo_width
24
+ #pragma mapbox: define lowp float halo_blur
25
+
26
+ uniform mat4 u_matrix;
27
+ uniform mat4 u_label_plane_matrix;
28
+ uniform mat4 u_gl_coord_matrix;
29
+
30
+ uniform bool u_is_text;
31
+ uniform bool u_pitch_with_map;
32
+ uniform highp float u_pitch;
33
+ uniform bool u_rotate_symbol;
34
+ uniform highp float u_aspect_ratio;
35
+ uniform highp float u_camera_to_center_distance;
36
+ uniform float u_fade_change;
37
+
38
+ uniform vec2 u_texsize;
39
+
40
+ varying vec2 v_data0;
41
+ varying vec3 v_data1;
42
+
43
+ void main() {
44
+ #pragma mapbox: initialize highp vec4 fill_color
45
+ #pragma mapbox: initialize highp vec4 halo_color
46
+ #pragma mapbox: initialize lowp float opacity
47
+ #pragma mapbox: initialize lowp float halo_width
48
+ #pragma mapbox: initialize lowp float halo_blur
49
+
50
+ vec2 a_pos = a_pos_offset.xy;
51
+ vec2 a_offset = a_pos_offset.zw;
52
+
53
+ vec2 a_tex = a_data.xy;
54
+ vec2 a_size = a_data.zw;
55
+
56
+ highp float segment_angle = -a_projected_pos[2];
57
+ float size;
58
+
59
+ if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
60
+ size = mix(a_size[0], a_size[1], u_size_t) / 10.0;
61
+ } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
62
+ size = a_size[0] / 10.0;
63
+ } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {
64
+ size = u_size;
65
+ } else {
66
+ size = u_size;
67
+ }
68
+
69
+ vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);
70
+ highp float camera_to_anchor_distance = projectedPoint.w;
71
+ // If the label is pitched with the map, layout is done in pitched space,
72
+ // which makes labels in the distance smaller relative to viewport space.
73
+ // We counteract part of that effect by multiplying by the perspective ratio.
74
+ // If the label isn't pitched with the map, we do layout in viewport space,
75
+ // which makes labels in the distance larger relative to the features around
76
+ // them. We counteract part of that effect by dividing by the perspective ratio.
77
+ highp float distance_ratio = u_pitch_with_map ?
78
+ camera_to_anchor_distance / u_camera_to_center_distance :
79
+ u_camera_to_center_distance / camera_to_anchor_distance;
80
+ highp float perspective_ratio = clamp(
81
+ 0.5 + 0.5 * distance_ratio,
82
+ 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
83
+ 4.0);
84
+
85
+ size *= perspective_ratio;
86
+
87
+ float fontScale = u_is_text ? size / 24.0 : size;
88
+
89
+ highp float symbol_rotation = 0.0;
90
+ if (u_rotate_symbol) {
91
+ // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units
92
+ // To figure out that angle in projected space, we draw a short horizontal line in tile
93
+ // space, project it, and measure its angle in projected space.
94
+ vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);
95
+
96
+ vec2 a = projectedPoint.xy / projectedPoint.w;
97
+ vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
98
+
99
+ symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
100
+ }
101
+
102
+ highp float angle_sin = sin(segment_angle + symbol_rotation);
103
+ highp float angle_cos = cos(segment_angle + symbol_rotation);
104
+ mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
105
+
106
+ vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
107
+ gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);
108
+ float gamma_scale = gl_Position.w;
109
+
110
+ vec2 tex = a_tex / u_texsize;
111
+ vec2 fade_opacity = unpack_opacity(a_fade_opacity);
112
+ float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
113
+ float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
114
+
115
+ v_data0 = vec2(tex.x, tex.y);
116
+ v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);
117
+ }