@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.
- package/LICENSE.txt +87 -0
- package/README.md +25 -0
- package/build/min/.dir +0 -0
- package/build/min/package.json +3 -0
- package/build/min/src/shaders/_prelude.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/_prelude.vertex.glsl.txt +14 -0
- package/build/min/src/shaders/background.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/background.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/background_pattern.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/background_pattern.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/circle.fragment.glsl.txt +20 -0
- package/build/min/src/shaders/circle.vertex.glsl.txt +17 -0
- package/build/min/src/shaders/clipping_mask.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/clipping_mask.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/collision_box.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/collision_box.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/collision_circle.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/collision_circle.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/debug.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/debug.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/fill.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/fill.vertex.glsl.txt +7 -0
- package/build/min/src/shaders/fill_extrusion.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/fill_extrusion.vertex.glsl.txt +9 -0
- package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.txt +15 -0
- package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.txt +11 -0
- package/build/min/src/shaders/fill_outline.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/fill_outline.vertex.glsl.txt +7 -0
- package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.txt +9 -0
- package/build/min/src/shaders/fill_pattern.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/fill_pattern.vertex.glsl.txt +9 -0
- package/build/min/src/shaders/heatmap.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/heatmap.vertex.glsl.txt +8 -0
- package/build/min/src/shaders/heatmap_texture.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/heatmap_texture.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/hillshade.fragment.glsl.txt +7 -0
- package/build/min/src/shaders/hillshade.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/hillshade_prepare.fragment.glsl.txt +8 -0
- package/build/min/src/shaders/hillshade_prepare.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/line.fragment.glsl.txt +12 -0
- package/build/min/src/shaders/line.vertex.glsl.txt +17 -0
- package/build/min/src/shaders/line_gradient.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/line_gradient.vertex.glsl.txt +16 -0
- package/build/min/src/shaders/line_pattern.fragment.glsl.txt +15 -0
- package/build/min/src/shaders/line_pattern.vertex.glsl.txt +20 -0
- package/build/min/src/shaders/line_sdf.fragment.glsl.txt +17 -0
- package/build/min/src/shaders/line_sdf.vertex.glsl.txt +20 -0
- package/build/min/src/shaders/raster.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/raster.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/symbol_icon.fragment.glsl.txt +9 -0
- package/build/min/src/shaders/symbol_icon.vertex.glsl.txt +5 -0
- package/build/min/src/shaders/symbol_sdf.fragment.glsl.txt +19 -0
- package/build/min/src/shaders/symbol_sdf.vertex.glsl.txt +13 -0
- package/package.json +44 -0
- package/src/css/mapbox-gl.css +506 -0
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-geolocate-background.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-logo-compact.svg +2 -0
- package/src/css/svg/mapboxgl-ctrl-logo.svg +1 -0
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
- package/src/data/array_types.js +1138 -0
- package/src/data/bucket/circle_attributes.js +5 -0
- package/src/data/bucket/circle_bucket.js +118 -0
- package/src/data/bucket/fill_attributes.js +5 -0
- package/src/data/bucket/fill_bucket.js +166 -0
- package/src/data/bucket/fill_extrusion_attributes.js +11 -0
- package/src/data/bucket/fill_extrusion_bucket.js +247 -0
- package/src/data/bucket/heatmap_bucket.js +12 -0
- package/src/data/bucket/line_attributes.js +11 -0
- package/src/data/bucket/line_bucket.js +625 -0
- package/src/data/bucket/pattern_attributes.js +9 -0
- package/src/data/bucket/pattern_bucket_features.js +44 -0
- package/src/data/bucket/symbol_attributes.js +95 -0
- package/src/data/bucket/symbol_bucket.js +697 -0
- package/src/data/bucket.js +53 -0
- package/src/data/dem_data.js +126 -0
- package/src/data/extent.js +17 -0
- package/src/data/feature_index.js +254 -0
- package/src/data/index_array_type.js +14 -0
- package/src/data/load_geometry.js +42 -0
- package/src/data/pos_attributes.js +3 -0
- package/src/data/program_configuration.js +782 -0
- package/src/data/raster_bounds_attributes.js +6 -0
- package/src/data/segment.js +63 -0
- package/src/geo/coordinate.js +78 -0
- package/src/geo/lng_lat.js +129 -0
- package/src/geo/lng_lat_bounds.js +253 -0
- package/src/geo/transform.js +605 -0
- package/src/gl/color_mode.js +21 -0
- package/src/gl/context.js +193 -0
- package/src/gl/cull_face_mode.js +22 -0
- package/src/gl/depth_mode.js +18 -0
- package/src/gl/framebuffer.js +28 -0
- package/src/gl/index_buffer.js +52 -0
- package/src/gl/stencil_mode.js +17 -0
- package/src/gl/types.js +0 -0
- package/src/gl/value.js +676 -0
- package/src/gl/vertex_buffer.js +101 -0
- package/src/index.js +50 -0
- package/src/render/draw_background.js +60 -0
- package/src/render/draw_circle.js +55 -0
- package/src/render/draw_collision_debug.js +45 -0
- package/src/render/draw_debug.js +429 -0
- package/src/render/draw_fill.js +143 -0
- package/src/render/draw_fill_extrusion.js +101 -0
- package/src/render/draw_heatmap.js +159 -0
- package/src/render/draw_hillshade.js +144 -0
- package/src/render/draw_line.js +99 -0
- package/src/render/draw_raster.js +151 -0
- package/src/render/draw_symbol.js +231 -0
- package/src/render/glyph_atlas.js +55 -0
- package/src/render/glyph_manager.js +145 -0
- package/src/render/image_atlas.js +97 -0
- package/src/render/image_manager.js +183 -0
- package/src/render/line_atlas.js +139 -0
- package/src/render/painter.js +483 -0
- package/src/render/program/background_program.js +46 -0
- package/src/render/program/circle_program.js +40 -0
- package/src/render/program/clipping_mask_program.js +11 -0
- package/src/render/program/collision_program.js +28 -0
- package/src/render/program/debug_program.js +13 -0
- package/src/render/program/fill_extrusion_program.js +76 -0
- package/src/render/program/fill_program.js +60 -0
- package/src/render/program/heatmap_program.js +46 -0
- package/src/render/program/hillshade_program.js +77 -0
- package/src/render/program/line_program.js +119 -0
- package/src/render/program/pattern.js +57 -0
- package/src/render/program/program_uniforms.js +46 -0
- package/src/render/program/raster_program.js +50 -0
- package/src/render/program/symbol_program.js +112 -0
- package/src/render/program.js +133 -0
- package/src/render/texture.js +88 -0
- package/src/render/tile_mask.js +108 -0
- package/src/render/uniform_binding.js +129 -0
- package/src/render/vertex_array_object.js +155 -0
- package/src/shaders/README.md +42 -0
- package/src/shaders/_prelude.fragment.glsl +17 -0
- package/src/shaders/_prelude.vertex.glsl +73 -0
- package/src/shaders/background.fragment.glsl +10 -0
- package/src/shaders/background.vertex.glsl +7 -0
- package/src/shaders/background_pattern.fragment.glsl +28 -0
- package/src/shaders/background_pattern.vertex.glsl +20 -0
- package/src/shaders/circle.fragment.glsl +39 -0
- package/src/shaders/circle.vertex.glsl +63 -0
- package/src/shaders/clipping_mask.fragment.glsl +3 -0
- package/src/shaders/clipping_mask.vertex.glsl +7 -0
- package/src/shaders/collision_box.fragment.glsl +21 -0
- package/src/shaders/collision_box.vertex.glsl +26 -0
- package/src/shaders/collision_circle.fragment.glsl +34 -0
- package/src/shaders/collision_circle.vertex.glsl +36 -0
- package/src/shaders/debug.fragment.glsl +5 -0
- package/src/shaders/debug.vertex.glsl +7 -0
- package/src/shaders/encode_attribute.js +19 -0
- package/src/shaders/fill.fragment.glsl +13 -0
- package/src/shaders/fill.vertex.glsl +13 -0
- package/src/shaders/fill_extrusion.fragment.glsl +16 -0
- package/src/shaders/fill_extrusion.vertex.glsl +66 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +41 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +76 -0
- package/src/shaders/fill_outline.fragment.glsl +17 -0
- package/src/shaders/fill_outline.vertex.glsl +17 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl +41 -0
- package/src/shaders/fill_pattern.fragment.glsl +36 -0
- package/src/shaders/fill_pattern.vertex.glsl +36 -0
- package/src/shaders/heatmap.fragment.glsl +21 -0
- package/src/shaders/heatmap.vertex.glsl +53 -0
- package/src/shaders/heatmap_texture.fragment.glsl +14 -0
- package/src/shaders/heatmap_texture.vertex.glsl +11 -0
- package/src/shaders/hillshade.fragment.glsl +52 -0
- package/src/shaders/hillshade.vertex.glsl +11 -0
- package/src/shaders/hillshade_prepare.fragment.glsl +72 -0
- package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
- package/src/shaders/index.js +194 -0
- package/src/shaders/line.fragment.glsl +28 -0
- package/src/shaders/line.vertex.glsl +84 -0
- package/src/shaders/line_gradient.fragment.glsl +34 -0
- package/src/shaders/line_gradient.vertex.glsl +84 -0
- package/src/shaders/line_pattern.fragment.glsl +69 -0
- package/src/shaders/line_pattern.vertex.glsl +88 -0
- package/src/shaders/line_sdf.fragment.glsl +44 -0
- package/src/shaders/line_sdf.vertex.glsl +95 -0
- package/src/shaders/raster.fragment.glsl +52 -0
- package/src/shaders/raster.vertex.glsl +21 -0
- package/src/shaders/symbol_icon.fragment.glsl +17 -0
- package/src/shaders/symbol_icon.vertex.glsl +91 -0
- package/src/shaders/symbol_sdf.fragment.glsl +50 -0
- package/src/shaders/symbol_sdf.vertex.glsl +117 -0
- package/src/source/geojson_source.js +267 -0
- package/src/source/geojson_worker_source.js +210 -0
- package/src/source/geojson_wrapper.js +67 -0
- package/src/source/image_source.js +213 -0
- package/src/source/load_tilejson.js +40 -0
- package/src/source/pixels_to_tile_units.js +17 -0
- package/src/source/query_features.js +198 -0
- package/src/source/raster_dem_tile_source.js +140 -0
- package/src/source/raster_dem_tile_worker_source.js +26 -0
- package/src/source/raster_tile_source.js +126 -0
- package/src/source/rtl_text_plugin.js +63 -0
- package/src/source/source.js +75 -0
- package/src/source/source_cache.js +794 -0
- package/src/source/source_state.js +55 -0
- package/src/source/tile.js +332 -0
- package/src/source/tile_bounds.js +40 -0
- package/src/source/tile_cache.js +122 -0
- package/src/source/tile_id.js +150 -0
- package/src/source/vector_tile_source.js +144 -0
- package/src/source/vector_tile_worker_source.js +126 -0
- package/src/source/worker.js +175 -0
- package/src/source/worker_source.js +14 -0
- package/src/source/worker_tile.js +199 -0
- package/src/style/create_style_layer.js +25 -0
- package/src/style/evaluation_parameters.js +45 -0
- package/src/style/light.js +112 -0
- package/src/style/load_glyph_range.js +17 -0
- package/src/style/load_sprite.js +26 -0
- package/src/style/parse_glyph_pbf.js +45 -0
- package/src/style/pauseable_placement.js +88 -0
- package/src/style/properties.js +691 -0
- package/src/style/query_utils.js +39 -0
- package/src/style/style.js +955 -0
- package/src/style/style_layer/background_style_layer.js +11 -0
- package/src/style/style_layer/background_style_layer_properties.js +25 -0
- package/src/style/style_layer/circle_style_layer.js +93 -0
- package/src/style/style_layer/circle_style_layer_properties.js +76 -0
- package/src/style/style_layer/fill_extrusion_style_layer.js +194 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +56 -0
- package/src/style/style_layer/fill_style_layer.js +46 -0
- package/src/style/style_layer/fill_style_layer_properties.js +45 -0
- package/src/style/style_layer/heatmap_style_layer.js +51 -0
- package/src/style/style_layer/heatmap_style_layer_properties.js +52 -0
- package/src/style/style_layer/hillshade_style_layer.js +15 -0
- package/src/style/style_layer/hillshade_style_layer_properties.js +43 -0
- package/src/style/style_layer/line_style_layer.js +129 -0
- package/src/style/style_layer/line_style_layer_properties.js +104 -0
- package/src/style/style_layer/raster_style_layer.js +11 -0
- package/src/style/style_layer/raster_style_layer_properties.js +55 -0
- package/src/style/style_layer/symbol_style_layer.js +66 -0
- package/src/style/style_layer/symbol_style_layer_properties.js +288 -0
- package/src/style/style_layer.js +183 -0
- package/src/style/style_layer_index.js +61 -0
- package/src/style/zoom_history.js +36 -0
- package/src/style-spec/deref.js +51 -0
- package/src/style-spec/error/parsing_error.js +8 -0
- package/src/style-spec/error/validation_error.js +10 -0
- package/src/style-spec/expression/compound_expression.js +118 -0
- package/src/style-spec/expression/definitions/array.js +82 -0
- package/src/style-spec/expression/definitions/assertion.js +69 -0
- package/src/style-spec/expression/definitions/at.js +57 -0
- package/src/style-spec/expression/definitions/case.js +73 -0
- package/src/style-spec/expression/definitions/coalesce.js +68 -0
- package/src/style-spec/expression/definitions/coercion.js +96 -0
- package/src/style-spec/expression/definitions/collator.js +102 -0
- package/src/style-spec/expression/definitions/equals.js +93 -0
- package/src/style-spec/expression/definitions/index.js +407 -0
- package/src/style-spec/expression/definitions/interpolate.js +235 -0
- package/src/style-spec/expression/definitions/length.js +54 -0
- package/src/style-spec/expression/definitions/let.js +60 -0
- package/src/style-spec/expression/definitions/literal.js +64 -0
- package/src/style-spec/expression/definitions/match.js +142 -0
- package/src/style-spec/expression/definitions/step.js +116 -0
- package/src/style-spec/expression/definitions/var.js +38 -0
- package/src/style-spec/expression/evaluation_context.js +35 -0
- package/src/style-spec/expression/index.js +329 -0
- package/src/style-spec/expression/is_constant.js +63 -0
- package/src/style-spec/expression/parsing_context.js +213 -0
- package/src/style-spec/expression/parsing_error.js +9 -0
- package/src/style-spec/expression/runtime_error.js +12 -0
- package/src/style-spec/expression/scope.js +34 -0
- package/src/style-spec/expression/stops.js +37 -0
- package/src/style-spec/expression/types.js +77 -0
- package/src/style-spec/expression/values.js +126 -0
- package/src/style-spec/feature_filter/README.md +55 -0
- package/src/style-spec/feature_filter/index.js +158 -0
- package/src/style-spec/function/convert.js +256 -0
- package/src/style-spec/function/index.js +299 -0
- package/src/style-spec/group_by_layout.js +68 -0
- package/src/style-spec/reference/v8.json +5356 -0
- package/src/style-spec/util/color.js +73 -0
- package/src/style-spec/util/color_spaces.js +128 -0
- package/src/style-spec/util/eval_support.js +8 -0
- package/src/style-spec/util/get_type.js +18 -0
- package/src/style-spec/util/interpolate.js +21 -0
- package/src/style-spec/util/properties.js +17 -0
- package/src/style-spec/util/ref_properties.js +1 -0
- package/src/style-spec/util/result.js +19 -0
- package/src/symbol/anchor.js +21 -0
- package/src/symbol/check_max_angle.js +75 -0
- package/src/symbol/clip_line.js +73 -0
- package/src/symbol/collision_feature.js +230 -0
- package/src/symbol/collision_index.js +379 -0
- package/src/symbol/cross_tile_symbol_index.js +270 -0
- package/src/symbol/get_anchors.js +177 -0
- package/src/symbol/grid_index.js +318 -0
- package/src/symbol/mergelines.js +75 -0
- package/src/symbol/opacity_state.js +21 -0
- package/src/symbol/placement.js +563 -0
- package/src/symbol/projection.js +601 -0
- package/src/symbol/quads.js +173 -0
- package/src/symbol/shaping.js +347 -0
- package/src/symbol/symbol_layout.js +519 -0
- package/src/symbol/symbol_size.js +110 -0
- package/src/symbol/transform_text.js +16 -0
- package/src/ui/anchor.js +24 -0
- package/src/ui/bind_handlers.js +199 -0
- package/src/ui/camera.js +954 -0
- package/src/ui/events.js +210 -0
- package/src/ui/handler/box_zoom.js +151 -0
- package/src/ui/handler/dblclick_zoom.js +91 -0
- package/src/ui/handler/drag_pan.js +285 -0
- package/src/ui/handler/drag_rotate.js +290 -0
- package/src/ui/handler/frame.js +28 -0
- package/src/ui/handler/inertia.js +45 -0
- package/src/ui/handler/keyboard.js +148 -0
- package/src/ui/handler/scroll_zoom.js +284 -0
- package/src/ui/handler/touch_zoom_rotate.js +263 -0
- package/src/ui/map.js +1645 -0
- package/src/util/actor.js +104 -0
- package/src/util/async.js +23 -0
- package/src/util/browser.js +61 -0
- package/src/util/callback.js +26 -0
- package/src/util/classify_rings.js +43 -0
- package/src/util/color_ramp.js +24 -0
- package/src/util/config.js +24 -0
- package/src/util/dictionary_coder.js +25 -0
- package/src/util/dispatcher.js +68 -0
- package/src/util/dom.js +102 -0
- package/src/util/evented.js +182 -0
- package/src/util/find_pole_of_inaccessibility.js +129 -0
- package/src/util/global_worker_pool.js +15 -0
- package/src/util/image.js +124 -0
- package/src/util/interpolate.js +5 -0
- package/src/util/intersection_tests.js +207 -0
- package/src/util/is_char_in_unicode_block.js +287 -0
- package/src/util/loader/image.js +32 -0
- package/src/util/object.js +178 -0
- package/src/util/script_detection.js +337 -0
- package/src/util/struct_array.js +197 -0
- package/src/util/task_queue.js +57 -0
- package/src/util/throttle.js +26 -0
- package/src/util/tile_cover.js +114 -0
- package/src/util/token.js +13 -0
- package/src/util/unique_id.js +12 -0
- package/src/util/util.js +192 -0
- package/src/util/vectortile_to_geojson.js +44 -0
- package/src/util/verticalize_punctuation.js +112 -0
- package/src/util/warn.js +21 -0
- package/src/util/web_worker.js +5 -0
- package/src/util/web_worker_transfer.js +228 -0
- package/src/util/worker_pool.js +41 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const shaders = {
|
|
2
|
+
prelude: {
|
|
3
|
+
fragmentSource: require('../../build/min/src/shaders/_prelude.fragment.glsl.txt'),
|
|
4
|
+
vertexSource: require('../../build/min/src/shaders/_prelude.vertex.glsl.txt')
|
|
5
|
+
},
|
|
6
|
+
background: {
|
|
7
|
+
fragmentSource: require('../../build/min/src/shaders/background.fragment.glsl.txt'),
|
|
8
|
+
vertexSource: require('../../build/min/src/shaders/background.vertex.glsl.txt')
|
|
9
|
+
},
|
|
10
|
+
backgroundPattern: {
|
|
11
|
+
fragmentSource: require('../../build/min/src/shaders/background_pattern.fragment.glsl.txt'),
|
|
12
|
+
vertexSource: require('../../build/min/src/shaders/background_pattern.vertex.glsl.txt')
|
|
13
|
+
},
|
|
14
|
+
circle: {
|
|
15
|
+
fragmentSource: require('../../build/min/src/shaders/circle.fragment.glsl.txt'),
|
|
16
|
+
vertexSource: require('../../build/min/src/shaders/circle.vertex.glsl.txt')
|
|
17
|
+
},
|
|
18
|
+
clippingMask: {
|
|
19
|
+
fragmentSource: require('../../build/min/src/shaders/clipping_mask.fragment.glsl.txt'),
|
|
20
|
+
vertexSource: require('../../build/min/src/shaders/clipping_mask.vertex.glsl.txt')
|
|
21
|
+
},
|
|
22
|
+
heatmap: {
|
|
23
|
+
fragmentSource: require('../../build/min/src/shaders/heatmap.fragment.glsl.txt'),
|
|
24
|
+
vertexSource: require('../../build/min/src/shaders/heatmap.vertex.glsl.txt')
|
|
25
|
+
},
|
|
26
|
+
heatmapTexture: {
|
|
27
|
+
fragmentSource: require('../../build/min/src/shaders/heatmap_texture.fragment.glsl.txt'),
|
|
28
|
+
vertexSource: require('../../build/min/src/shaders/heatmap_texture.vertex.glsl.txt')
|
|
29
|
+
},
|
|
30
|
+
collisionBox: {
|
|
31
|
+
fragmentSource: require('../../build/min/src/shaders/collision_box.fragment.glsl.txt'),
|
|
32
|
+
vertexSource: require('../../build/min/src/shaders/collision_box.vertex.glsl.txt')
|
|
33
|
+
},
|
|
34
|
+
collisionCircle: {
|
|
35
|
+
fragmentSource: require('../../build/min/src/shaders/collision_circle.fragment.glsl.txt'),
|
|
36
|
+
vertexSource: require('../../build/min/src/shaders/collision_circle.vertex.glsl.txt')
|
|
37
|
+
},
|
|
38
|
+
debug: {
|
|
39
|
+
fragmentSource: require('../../build/min/src/shaders/debug.fragment.glsl.txt'),
|
|
40
|
+
vertexSource: require('../../build/min/src/shaders/debug.vertex.glsl.txt')
|
|
41
|
+
},
|
|
42
|
+
fill: {
|
|
43
|
+
fragmentSource: require('../../build/min/src/shaders/fill.fragment.glsl.txt'),
|
|
44
|
+
vertexSource: require('../../build/min/src/shaders/fill.vertex.glsl.txt')
|
|
45
|
+
},
|
|
46
|
+
fillOutline: {
|
|
47
|
+
fragmentSource: require('../../build/min/src/shaders/fill_outline.fragment.glsl.txt'),
|
|
48
|
+
vertexSource: require('../../build/min/src/shaders/fill_outline.vertex.glsl.txt')
|
|
49
|
+
},
|
|
50
|
+
fillOutlinePattern: {
|
|
51
|
+
fragmentSource: require('../../build/min/src/shaders/fill_outline_pattern.fragment.glsl.txt'),
|
|
52
|
+
vertexSource: require('../../build/min/src/shaders/fill_outline_pattern.vertex.glsl.txt')
|
|
53
|
+
},
|
|
54
|
+
fillPattern: {
|
|
55
|
+
fragmentSource: require('../../build/min/src/shaders/fill_pattern.fragment.glsl.txt'),
|
|
56
|
+
vertexSource: require('../../build/min/src/shaders/fill_pattern.vertex.glsl.txt')
|
|
57
|
+
},
|
|
58
|
+
fillExtrusion: {
|
|
59
|
+
fragmentSource: require('../../build/min/src/shaders/fill_extrusion.fragment.glsl.txt'),
|
|
60
|
+
vertexSource: require('../../build/min/src/shaders/fill_extrusion.vertex.glsl.txt')
|
|
61
|
+
},
|
|
62
|
+
fillExtrusionPattern: {
|
|
63
|
+
fragmentSource: require('../../build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.txt'),
|
|
64
|
+
vertexSource: require('../../build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.txt')
|
|
65
|
+
},
|
|
66
|
+
hillshadePrepare: {
|
|
67
|
+
fragmentSource: require('../../build/min/src/shaders/hillshade_prepare.fragment.glsl.txt'),
|
|
68
|
+
vertexSource: require('../../build/min/src/shaders/hillshade_prepare.vertex.glsl.txt')
|
|
69
|
+
},
|
|
70
|
+
hillshade: {
|
|
71
|
+
fragmentSource: require('../../build/min/src/shaders/hillshade.fragment.glsl.txt'),
|
|
72
|
+
vertexSource: require('../../build/min/src/shaders/hillshade.vertex.glsl.txt')
|
|
73
|
+
},
|
|
74
|
+
line: {
|
|
75
|
+
fragmentSource: require('../../build/min/src/shaders/line.fragment.glsl.txt'),
|
|
76
|
+
vertexSource: require('../../build/min/src/shaders/line.vertex.glsl.txt')
|
|
77
|
+
},
|
|
78
|
+
lineGradient: {
|
|
79
|
+
fragmentSource: require('../../build/min/src/shaders/line_gradient.fragment.glsl.txt'),
|
|
80
|
+
vertexSource: require('../../build/min/src/shaders/line_gradient.vertex.glsl.txt')
|
|
81
|
+
},
|
|
82
|
+
linePattern: {
|
|
83
|
+
fragmentSource: require('../../build/min/src/shaders/line_pattern.fragment.glsl.txt'),
|
|
84
|
+
vertexSource: require('../../build/min/src/shaders/line_pattern.vertex.glsl.txt')
|
|
85
|
+
},
|
|
86
|
+
lineSDF: {
|
|
87
|
+
fragmentSource: require('../../build/min/src/shaders/line_sdf.fragment.glsl.txt'),
|
|
88
|
+
vertexSource: require('../../build/min/src/shaders/line_sdf.vertex.glsl.txt')
|
|
89
|
+
},
|
|
90
|
+
raster: {
|
|
91
|
+
fragmentSource: require('../../build/min/src/shaders/raster.fragment.glsl.txt'),
|
|
92
|
+
vertexSource: require('../../build/min/src/shaders/raster.vertex.glsl.txt')
|
|
93
|
+
},
|
|
94
|
+
symbolIcon: {
|
|
95
|
+
fragmentSource: require('../../build/min/src/shaders/symbol_icon.fragment.glsl.txt'),
|
|
96
|
+
vertexSource: require('../../build/min/src/shaders/symbol_icon.vertex.glsl.txt')
|
|
97
|
+
},
|
|
98
|
+
symbolSDF: {
|
|
99
|
+
fragmentSource: require('../../build/min/src/shaders/symbol_sdf.fragment.glsl.txt'),
|
|
100
|
+
vertexSource: require('../../build/min/src/shaders/symbol_sdf.vertex.glsl.txt')
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Expand #pragmas to #ifdefs.
|
|
105
|
+
|
|
106
|
+
const re = /#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g;
|
|
107
|
+
|
|
108
|
+
for (const programName in shaders) {
|
|
109
|
+
const program = shaders[programName];
|
|
110
|
+
const fragmentPragmas = {};
|
|
111
|
+
|
|
112
|
+
program.fragmentSource = program.fragmentSource.replace(re, (match, operation, precision, type, name) => {
|
|
113
|
+
fragmentPragmas[name] = true;
|
|
114
|
+
if (operation === 'define') {
|
|
115
|
+
return `
|
|
116
|
+
#ifndef HAS_UNIFORM_u_${name}
|
|
117
|
+
varying ${precision} ${type} ${name};
|
|
118
|
+
#else
|
|
119
|
+
uniform ${precision} ${type} u_${name};
|
|
120
|
+
#endif
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
return `
|
|
124
|
+
#ifdef HAS_UNIFORM_u_${name}
|
|
125
|
+
${precision} ${type} ${name} = u_${name};
|
|
126
|
+
#endif
|
|
127
|
+
`;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
program.vertexSource = program.vertexSource.replace(re, (match, operation, precision, type, name) => {
|
|
131
|
+
const attrType = type === 'float' ? 'vec2' : 'vec4';
|
|
132
|
+
const unpackType = name.match(/color/) ? 'color' : attrType;
|
|
133
|
+
|
|
134
|
+
if (fragmentPragmas[name]) {
|
|
135
|
+
if (operation === 'define') {
|
|
136
|
+
return `
|
|
137
|
+
#ifndef HAS_UNIFORM_u_${name}
|
|
138
|
+
uniform lowp float a_${name}_t;
|
|
139
|
+
attribute ${precision} ${attrType} a_${name};
|
|
140
|
+
varying ${precision} ${type} ${name};
|
|
141
|
+
#else
|
|
142
|
+
uniform ${precision} ${type} u_${name};
|
|
143
|
+
#endif
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
if (unpackType === 'vec4') {
|
|
147
|
+
// vec4 attributes are only used for cross-faded properties, and are not packed
|
|
148
|
+
return `
|
|
149
|
+
#ifndef HAS_UNIFORM_u_${name}
|
|
150
|
+
${name} = a_${name};
|
|
151
|
+
#else
|
|
152
|
+
${precision} ${type} ${name} = u_${name};
|
|
153
|
+
#endif
|
|
154
|
+
`;
|
|
155
|
+
}
|
|
156
|
+
return `
|
|
157
|
+
#ifndef HAS_UNIFORM_u_${name}
|
|
158
|
+
${name} = unpack_mix_${unpackType}(a_${name}, a_${name}_t);
|
|
159
|
+
#else
|
|
160
|
+
${precision} ${type} ${name} = u_${name};
|
|
161
|
+
#endif
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
if (operation === 'define') {
|
|
165
|
+
return `
|
|
166
|
+
#ifndef HAS_UNIFORM_u_${name}
|
|
167
|
+
uniform lowp float a_${name}_t;
|
|
168
|
+
attribute ${precision} ${attrType} a_${name};
|
|
169
|
+
#else
|
|
170
|
+
uniform ${precision} ${type} u_${name};
|
|
171
|
+
#endif
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
if (unpackType === 'vec4') {
|
|
175
|
+
// vec4 attributes are only used for cross-faded properties, and are not packed
|
|
176
|
+
return `
|
|
177
|
+
#ifndef HAS_UNIFORM_u_${name}
|
|
178
|
+
${precision} ${type} ${name} = a_${name};
|
|
179
|
+
#else
|
|
180
|
+
${precision} ${type} ${name} = u_${name};
|
|
181
|
+
#endif
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
return `
|
|
185
|
+
#ifndef HAS_UNIFORM_u_${name}
|
|
186
|
+
${precision} ${type} ${name} = unpack_mix_${unpackType}(a_${name}, a_${name}_t);
|
|
187
|
+
#else
|
|
188
|
+
${precision} ${type} ${name} = u_${name};
|
|
189
|
+
#endif
|
|
190
|
+
`;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
module.exports = shaders;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma mapbox: define highp vec4 color
|
|
2
|
+
#pragma mapbox: define lowp float blur
|
|
3
|
+
#pragma mapbox: define lowp float opacity
|
|
4
|
+
|
|
5
|
+
varying vec2 v_width2;
|
|
6
|
+
varying vec2 v_normal;
|
|
7
|
+
varying float v_gamma_scale;
|
|
8
|
+
|
|
9
|
+
void main() {
|
|
10
|
+
#pragma mapbox: initialize highp vec4 color
|
|
11
|
+
#pragma mapbox: initialize lowp float blur
|
|
12
|
+
#pragma mapbox: initialize lowp float opacity
|
|
13
|
+
|
|
14
|
+
// Calculate the distance of the pixel from the line in pixels.
|
|
15
|
+
float dist = length(v_normal) * v_width2.s;
|
|
16
|
+
|
|
17
|
+
// Calculate the antialiasing fade factor. This is either when fading in
|
|
18
|
+
// the line in case of an offset line (v_width2.t) or when fading out
|
|
19
|
+
// (v_width2.s)
|
|
20
|
+
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
|
21
|
+
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
|
22
|
+
|
|
23
|
+
gl_FragColor = color * (alpha * opacity);
|
|
24
|
+
|
|
25
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
26
|
+
gl_FragColor = vec4(1.0);
|
|
27
|
+
#endif
|
|
28
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// the distance over which the line edge fades out.
|
|
4
|
+
// Retina devices need a smaller distance to avoid aliasing.
|
|
5
|
+
#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0
|
|
6
|
+
|
|
7
|
+
// floor(127 / 2) == 63.0
|
|
8
|
+
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
|
9
|
+
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
|
10
|
+
// there are also "special" normals that have a bigger length (of up to 126 in
|
|
11
|
+
// this case).
|
|
12
|
+
// #define scale 63.0
|
|
13
|
+
#define scale 0.015873016
|
|
14
|
+
|
|
15
|
+
attribute vec4 a_pos_normal;
|
|
16
|
+
attribute vec4 a_data;
|
|
17
|
+
|
|
18
|
+
uniform mat4 u_matrix;
|
|
19
|
+
uniform mediump float u_ratio;
|
|
20
|
+
uniform vec2 u_gl_units_to_pixels;
|
|
21
|
+
|
|
22
|
+
varying vec2 v_normal;
|
|
23
|
+
varying vec2 v_width2;
|
|
24
|
+
varying float v_gamma_scale;
|
|
25
|
+
varying highp float v_linesofar;
|
|
26
|
+
|
|
27
|
+
#pragma mapbox: define highp vec4 color
|
|
28
|
+
#pragma mapbox: define lowp float blur
|
|
29
|
+
#pragma mapbox: define lowp float opacity
|
|
30
|
+
#pragma mapbox: define mediump float gapwidth
|
|
31
|
+
#pragma mapbox: define lowp float offset
|
|
32
|
+
#pragma mapbox: define mediump float width
|
|
33
|
+
|
|
34
|
+
void main() {
|
|
35
|
+
#pragma mapbox: initialize highp vec4 color
|
|
36
|
+
#pragma mapbox: initialize lowp float blur
|
|
37
|
+
#pragma mapbox: initialize lowp float opacity
|
|
38
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
39
|
+
#pragma mapbox: initialize lowp float offset
|
|
40
|
+
#pragma mapbox: initialize mediump float width
|
|
41
|
+
|
|
42
|
+
vec2 a_extrude = a_data.xy - 128.0;
|
|
43
|
+
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
|
44
|
+
|
|
45
|
+
v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;
|
|
46
|
+
|
|
47
|
+
vec2 pos = a_pos_normal.xy;
|
|
48
|
+
|
|
49
|
+
// x is 1 if it's a round cap, 0 otherwise
|
|
50
|
+
// y is 1 if the normal points up, and -1 if it points down
|
|
51
|
+
mediump vec2 normal = a_pos_normal.zw;
|
|
52
|
+
v_normal = normal;
|
|
53
|
+
|
|
54
|
+
// these transformations used to be applied in the JS and native code bases.
|
|
55
|
+
// moved them into the shader for clarity and simplicity.
|
|
56
|
+
gapwidth = gapwidth / 2.0;
|
|
57
|
+
float halfwidth = width / 2.0;
|
|
58
|
+
offset = -1.0 * offset;
|
|
59
|
+
|
|
60
|
+
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
|
61
|
+
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
|
62
|
+
|
|
63
|
+
// Scale the extrusion vector down to a normal and then up by the line width
|
|
64
|
+
// of this vertex.
|
|
65
|
+
mediump vec2 dist = outset * a_extrude * scale;
|
|
66
|
+
|
|
67
|
+
// Calculate the offset when drawing a line that is to the side of the actual line.
|
|
68
|
+
// We do this by creating a vector that points towards the extrude, but rotate
|
|
69
|
+
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
|
70
|
+
// extrude vector points in another direction.
|
|
71
|
+
mediump float u = 0.5 * a_direction;
|
|
72
|
+
mediump float t = 1.0 - abs(u);
|
|
73
|
+
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
|
74
|
+
|
|
75
|
+
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
|
76
|
+
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
|
77
|
+
|
|
78
|
+
// calculate how much the perspective view squishes or stretches the extrude
|
|
79
|
+
float extrude_length_without_perspective = length(dist);
|
|
80
|
+
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);
|
|
81
|
+
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
|
82
|
+
|
|
83
|
+
v_width2 = vec2(outset, inset);
|
|
84
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
#pragma mapbox: define lowp float blur
|
|
3
|
+
#pragma mapbox: define lowp float opacity
|
|
4
|
+
|
|
5
|
+
uniform sampler2D u_image;
|
|
6
|
+
|
|
7
|
+
varying vec2 v_width2;
|
|
8
|
+
varying vec2 v_normal;
|
|
9
|
+
varying float v_gamma_scale;
|
|
10
|
+
varying highp float v_lineprogress;
|
|
11
|
+
|
|
12
|
+
void main() {
|
|
13
|
+
#pragma mapbox: initialize lowp float blur
|
|
14
|
+
#pragma mapbox: initialize lowp float opacity
|
|
15
|
+
|
|
16
|
+
// Calculate the distance of the pixel from the line in pixels.
|
|
17
|
+
float dist = length(v_normal) * v_width2.s;
|
|
18
|
+
|
|
19
|
+
// Calculate the antialiasing fade factor. This is either when fading in
|
|
20
|
+
// the line in case of an offset line (v_width2.t) or when fading out
|
|
21
|
+
// (v_width2.s)
|
|
22
|
+
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
|
23
|
+
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
|
24
|
+
|
|
25
|
+
// For gradient lines, v_lineprogress is the ratio along the entire line,
|
|
26
|
+
// scaled to [0, 2^15), and the gradient ramp is stored in a texture.
|
|
27
|
+
vec4 color = texture2D(u_image, vec2(v_lineprogress, 0.5));
|
|
28
|
+
|
|
29
|
+
gl_FragColor = color * (alpha * opacity);
|
|
30
|
+
|
|
31
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
32
|
+
gl_FragColor = vec4(1.0);
|
|
33
|
+
#endif
|
|
34
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
// the attribute conveying progress along a line is scaled to [0, 2^15)
|
|
3
|
+
#define MAX_LINE_DISTANCE 32767.0
|
|
4
|
+
|
|
5
|
+
// the distance over which the line edge fades out.
|
|
6
|
+
// Retina devices need a smaller distance to avoid aliasing.
|
|
7
|
+
#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0
|
|
8
|
+
|
|
9
|
+
// floor(127 / 2) == 63.0
|
|
10
|
+
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
|
11
|
+
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
|
12
|
+
// there are also "special" normals that have a bigger length (of up to 126 in
|
|
13
|
+
// this case).
|
|
14
|
+
// #define scale 63.0
|
|
15
|
+
#define scale 0.015873016
|
|
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_gl_units_to_pixels;
|
|
23
|
+
|
|
24
|
+
varying vec2 v_normal;
|
|
25
|
+
varying vec2 v_width2;
|
|
26
|
+
varying float v_gamma_scale;
|
|
27
|
+
varying highp float v_lineprogress;
|
|
28
|
+
|
|
29
|
+
#pragma mapbox: define lowp float blur
|
|
30
|
+
#pragma mapbox: define lowp float opacity
|
|
31
|
+
#pragma mapbox: define mediump float gapwidth
|
|
32
|
+
#pragma mapbox: define lowp float offset
|
|
33
|
+
#pragma mapbox: define mediump float width
|
|
34
|
+
|
|
35
|
+
void main() {
|
|
36
|
+
#pragma mapbox: initialize lowp float blur
|
|
37
|
+
#pragma mapbox: initialize lowp float opacity
|
|
38
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
39
|
+
#pragma mapbox: initialize lowp float offset
|
|
40
|
+
#pragma mapbox: initialize mediump float width
|
|
41
|
+
|
|
42
|
+
vec2 a_extrude = a_data.xy - 128.0;
|
|
43
|
+
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
|
44
|
+
|
|
45
|
+
v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE;
|
|
46
|
+
|
|
47
|
+
vec2 pos = a_pos_normal.xy;
|
|
48
|
+
|
|
49
|
+
// x is 1 if it's a round cap, 0 otherwise
|
|
50
|
+
// y is 1 if the normal points up, and -1 if it points down
|
|
51
|
+
mediump vec2 normal = a_pos_normal.zw;
|
|
52
|
+
v_normal = normal;
|
|
53
|
+
|
|
54
|
+
// these transformations used to be applied in the JS and native code bases.
|
|
55
|
+
// moved them into the shader for clarity and simplicity.
|
|
56
|
+
gapwidth = gapwidth / 2.0;
|
|
57
|
+
float halfwidth = width / 2.0;
|
|
58
|
+
offset = -1.0 * offset;
|
|
59
|
+
|
|
60
|
+
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
|
61
|
+
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
|
62
|
+
|
|
63
|
+
// Scale the extrusion vector down to a normal and then up by the line width
|
|
64
|
+
// of this vertex.
|
|
65
|
+
mediump vec2 dist = outset * a_extrude * scale;
|
|
66
|
+
|
|
67
|
+
// Calculate the offset when drawing a line that is to the side of the actual line.
|
|
68
|
+
// We do this by creating a vector that points towards the extrude, but rotate
|
|
69
|
+
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
|
70
|
+
// extrude vector points in another direction.
|
|
71
|
+
mediump float u = 0.5 * a_direction;
|
|
72
|
+
mediump float t = 1.0 - abs(u);
|
|
73
|
+
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
|
74
|
+
|
|
75
|
+
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
|
76
|
+
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
|
77
|
+
|
|
78
|
+
// calculate how much the perspective view squishes or stretches the extrude
|
|
79
|
+
float extrude_length_without_perspective = length(dist);
|
|
80
|
+
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);
|
|
81
|
+
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
|
82
|
+
|
|
83
|
+
v_width2 = vec2(outset, inset);
|
|
84
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
uniform vec2 u_texsize;
|
|
2
|
+
uniform float u_fade;
|
|
3
|
+
uniform mediump vec4 u_scale;
|
|
4
|
+
|
|
5
|
+
uniform sampler2D u_image;
|
|
6
|
+
|
|
7
|
+
varying vec2 v_normal;
|
|
8
|
+
varying vec2 v_width2;
|
|
9
|
+
varying float v_linesofar;
|
|
10
|
+
varying float v_gamma_scale;
|
|
11
|
+
|
|
12
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
13
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
14
|
+
#pragma mapbox: define lowp float blur
|
|
15
|
+
#pragma mapbox: define lowp float opacity
|
|
16
|
+
|
|
17
|
+
void main() {
|
|
18
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
19
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
20
|
+
|
|
21
|
+
#pragma mapbox: initialize lowp float blur
|
|
22
|
+
#pragma mapbox: initialize lowp float opacity
|
|
23
|
+
|
|
24
|
+
vec2 pattern_tl_a = pattern_from.xy;
|
|
25
|
+
vec2 pattern_br_a = pattern_from.zw;
|
|
26
|
+
vec2 pattern_tl_b = pattern_to.xy;
|
|
27
|
+
vec2 pattern_br_b = pattern_to.zw;
|
|
28
|
+
|
|
29
|
+
float pixelRatio = u_scale.x;
|
|
30
|
+
float tileZoomRatio = u_scale.y;
|
|
31
|
+
float fromScale = u_scale.z;
|
|
32
|
+
float toScale = u_scale.w;
|
|
33
|
+
|
|
34
|
+
vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
|
|
35
|
+
vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
|
|
36
|
+
|
|
37
|
+
vec2 pattern_size_a = vec2(display_size_a.x * fromScale / tileZoomRatio, display_size_a.y);
|
|
38
|
+
vec2 pattern_size_b = vec2(display_size_b.x * toScale / tileZoomRatio, display_size_b.y);
|
|
39
|
+
|
|
40
|
+
// Calculate the distance of the pixel from the line in pixels.
|
|
41
|
+
float dist = length(v_normal) * v_width2.s;
|
|
42
|
+
|
|
43
|
+
// Calculate the antialiasing fade factor. This is either when fading in
|
|
44
|
+
// the line in case of an offset line (v_width2.t) or when fading out
|
|
45
|
+
// (v_width2.s)
|
|
46
|
+
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
|
47
|
+
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
|
48
|
+
|
|
49
|
+
float x_a = mod(v_linesofar / pattern_size_a.x, 1.0);
|
|
50
|
+
float x_b = mod(v_linesofar / pattern_size_b.x, 1.0);
|
|
51
|
+
|
|
52
|
+
// v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge
|
|
53
|
+
// we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0)
|
|
54
|
+
// to ensure we don't sample outside the designated symbol on the sprite sheet.
|
|
55
|
+
// 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of
|
|
56
|
+
// the texture coordinate
|
|
57
|
+
float y_a = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (pattern_size_a.y + 2.0) / 2.0) / pattern_size_a.y);
|
|
58
|
+
float y_b = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (pattern_size_b.y + 2.0) / 2.0) / pattern_size_b.y);
|
|
59
|
+
vec2 pos_a = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, vec2(x_a, y_a));
|
|
60
|
+
vec2 pos_b = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, vec2(x_b, y_b));
|
|
61
|
+
|
|
62
|
+
vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);
|
|
63
|
+
|
|
64
|
+
gl_FragColor = color * alpha * opacity;
|
|
65
|
+
|
|
66
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
67
|
+
gl_FragColor = vec4(1.0);
|
|
68
|
+
#endif
|
|
69
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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 vec2 u_gl_units_to_pixels;
|
|
22
|
+
uniform mediump float u_ratio;
|
|
23
|
+
|
|
24
|
+
varying vec2 v_normal;
|
|
25
|
+
varying vec2 v_width2;
|
|
26
|
+
varying float v_linesofar;
|
|
27
|
+
varying float v_gamma_scale;
|
|
28
|
+
|
|
29
|
+
#pragma mapbox: define lowp float blur
|
|
30
|
+
#pragma mapbox: define lowp float opacity
|
|
31
|
+
#pragma mapbox: define lowp float offset
|
|
32
|
+
#pragma mapbox: define mediump float gapwidth
|
|
33
|
+
#pragma mapbox: define mediump float width
|
|
34
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
35
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
36
|
+
|
|
37
|
+
void main() {
|
|
38
|
+
#pragma mapbox: initialize lowp float blur
|
|
39
|
+
#pragma mapbox: initialize lowp float opacity
|
|
40
|
+
#pragma mapbox: initialize lowp float offset
|
|
41
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
42
|
+
#pragma mapbox: initialize mediump float width
|
|
43
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
44
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
45
|
+
|
|
46
|
+
vec2 a_extrude = a_data.xy - 128.0;
|
|
47
|
+
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
|
48
|
+
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
|
|
49
|
+
// float tileRatio = u_scale.y;
|
|
50
|
+
vec2 pos = a_pos_normal.xy;
|
|
51
|
+
|
|
52
|
+
// x is 1 if it's a round cap, 0 otherwise
|
|
53
|
+
// y is 1 if the normal points up, and -1 if it points down
|
|
54
|
+
mediump vec2 normal = a_pos_normal.zw;
|
|
55
|
+
v_normal = normal;
|
|
56
|
+
|
|
57
|
+
// these transformations used to be applied in the JS and native code bases.
|
|
58
|
+
// moved them into the shader for clarity and simplicity.
|
|
59
|
+
gapwidth = gapwidth / 2.0;
|
|
60
|
+
float halfwidth = width / 2.0;
|
|
61
|
+
offset = -1.0 * offset;
|
|
62
|
+
|
|
63
|
+
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
|
64
|
+
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
|
65
|
+
|
|
66
|
+
// Scale the extrusion vector down to a normal and then up by the line width
|
|
67
|
+
// of this vertex.
|
|
68
|
+
mediump vec2 dist = outset * a_extrude * scale;
|
|
69
|
+
|
|
70
|
+
// Calculate the offset when drawing a line that is to the side of the actual line.
|
|
71
|
+
// We do this by creating a vector that points towards the extrude, but rotate
|
|
72
|
+
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
|
73
|
+
// extrude vector points in another direction.
|
|
74
|
+
mediump float u = 0.5 * a_direction;
|
|
75
|
+
mediump float t = 1.0 - abs(u);
|
|
76
|
+
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
|
77
|
+
|
|
78
|
+
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
|
79
|
+
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
|
80
|
+
|
|
81
|
+
// calculate how much the perspective view squishes or stretches the extrude
|
|
82
|
+
float extrude_length_without_perspective = length(dist);
|
|
83
|
+
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);
|
|
84
|
+
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
|
85
|
+
|
|
86
|
+
v_linesofar = a_linesofar;
|
|
87
|
+
v_width2 = vec2(outset, inset);
|
|
88
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
uniform sampler2D u_image;
|
|
3
|
+
uniform float u_sdfgamma;
|
|
4
|
+
uniform float u_mix;
|
|
5
|
+
|
|
6
|
+
varying vec2 v_normal;
|
|
7
|
+
varying vec2 v_width2;
|
|
8
|
+
varying vec2 v_tex_a;
|
|
9
|
+
varying vec2 v_tex_b;
|
|
10
|
+
varying float v_gamma_scale;
|
|
11
|
+
|
|
12
|
+
#pragma mapbox: define highp vec4 color
|
|
13
|
+
#pragma mapbox: define lowp float blur
|
|
14
|
+
#pragma mapbox: define lowp float opacity
|
|
15
|
+
#pragma mapbox: define mediump float width
|
|
16
|
+
#pragma mapbox: define lowp float floorwidth
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
#pragma mapbox: initialize highp vec4 color
|
|
20
|
+
#pragma mapbox: initialize lowp float blur
|
|
21
|
+
#pragma mapbox: initialize lowp float opacity
|
|
22
|
+
#pragma mapbox: initialize mediump float width
|
|
23
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
24
|
+
|
|
25
|
+
// Calculate the distance of the pixel from the line in pixels.
|
|
26
|
+
float dist = length(v_normal) * v_width2.s;
|
|
27
|
+
|
|
28
|
+
// Calculate the antialiasing fade factor. This is either when fading in
|
|
29
|
+
// the line in case of an offset line (v_width2.t) or when fading out
|
|
30
|
+
// (v_width2.s)
|
|
31
|
+
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
|
32
|
+
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
|
33
|
+
|
|
34
|
+
float sdfdist_a = texture2D(u_image, v_tex_a).a;
|
|
35
|
+
float sdfdist_b = texture2D(u_image, v_tex_b).a;
|
|
36
|
+
float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);
|
|
37
|
+
alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist);
|
|
38
|
+
|
|
39
|
+
gl_FragColor = color * (alpha * opacity);
|
|
40
|
+
|
|
41
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
42
|
+
gl_FragColor = vec4(1.0);
|
|
43
|
+
#endif
|
|
44
|
+
}
|