From a650df219d780976a68c542d956fc85de9fa6d05 Mon Sep 17 00:00:00 2001 From: Alex Cristici Date: Thu, 15 May 2025 22:53:09 +0300 Subject: [PATCH] Clean legacy code (#3469) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CMakeLists.txt | 90 +-- bazel/core.bzl | 90 +-- include/mbgl/gfx/fill_generator.hpp | 20 +- include/mbgl/shaders/gl/background.hpp | 18 +- .../mbgl/shaders/gl/background_pattern.hpp | 77 ++- include/mbgl/shaders/gl/circle.hpp | 104 ++-- include/mbgl/shaders/gl/collision_box.hpp | 34 +- include/mbgl/shaders/gl/collision_circle.hpp | 46 +- ...ustom_geometry.hpp => custom_geometry.hpp} | 6 +- ...symbol_icon.hpp => custom_symbol_icon.hpp} | 0 include/mbgl/shaders/gl/debug.hpp | 24 +- .../mbgl/shaders/gl/drawable_background.hpp | 38 -- .../gl/drawable_background_pattern.hpp | 94 --- include/mbgl/shaders/gl/drawable_circle.hpp | 242 -------- .../shaders/gl/drawable_collision_box.hpp | 80 --- .../shaders/gl/drawable_collision_circle.hpp | 119 ---- include/mbgl/shaders/gl/drawable_debug.hpp | 51 -- include/mbgl/shaders/gl/drawable_fill.hpp | 89 --- .../shaders/gl/drawable_fill_extrusion.hpp | 139 ----- .../gl/drawable_fill_extrusion_pattern.hpp | 237 -------- .../mbgl/shaders/gl/drawable_fill_outline.hpp | 108 ---- .../gl/drawable_fill_outline_pattern.hpp | 181 ------ .../mbgl/shaders/gl/drawable_fill_pattern.hpp | 174 ------ include/mbgl/shaders/gl/drawable_heatmap.hpp | 123 ---- .../shaders/gl/drawable_heatmap_texture.hpp | 66 --- .../mbgl/shaders/gl/drawable_hillshade.hpp | 86 --- .../shaders/gl/drawable_hillshade_prepare.hpp | 116 ---- include/mbgl/shaders/gl/drawable_line.hpp | 224 ------- .../shaders/gl/drawable_line_gradient.hpp | 220 ------- .../mbgl/shaders/gl/drawable_line_pattern.hpp | 295 ---------- include/mbgl/shaders/gl/drawable_line_sdf.hpp | 275 --------- include/mbgl/shaders/gl/drawable_raster.hpp | 108 ---- .../mbgl/shaders/gl/drawable_symbol_icon.hpp | 195 ------- .../gl/drawable_symbol_text_and_icon.hpp | 320 ---------- include/mbgl/shaders/gl/fill.hpp | 45 +- include/mbgl/shaders/gl/fill_extrusion.hpp | 61 +- .../shaders/gl/fill_extrusion_pattern.hpp | 130 +++-- include/mbgl/shaders/gl/fill_outline.hpp | 60 +- .../mbgl/shaders/gl/fill_outline_pattern.hpp | 105 ++-- ...ated.hpp => fill_outline_triangulated.hpp} | 0 include/mbgl/shaders/gl/fill_pattern.hpp | 104 ++-- include/mbgl/shaders/gl/heatmap.hpp | 44 +- include/mbgl/shaders/gl/heatmap_texture.hpp | 43 +- include/mbgl/shaders/gl/hillshade.hpp | 31 +- include/mbgl/shaders/gl/hillshade_prepare.hpp | 33 +- include/mbgl/shaders/gl/line.hpp | 84 +-- include/mbgl/shaders/gl/line_gradient.hpp | 80 ++- include/mbgl/shaders/gl/line_pattern.hpp | 122 ++-- include/mbgl/shaders/gl/line_sdf.hpp | 112 ++-- ...n_indicator.hpp => location_indicator.hpp} | 6 +- ...ed.hpp => location_indicator_textured.hpp} | 6 +- include/mbgl/shaders/gl/raster.hpp | 49 +- include/mbgl/shaders/gl/symbol_icon.hpp | 102 +++- ...drawable_symbol_sdf.hpp => symbol_sdf.hpp} | 0 include/mbgl/shaders/gl/symbol_sdf_icon.hpp | 261 --------- include/mbgl/shaders/gl/symbol_sdf_text.hpp | 261 --------- .../mbgl/shaders/gl/symbol_text_and_icon.hpp | 138 +++-- ...awable_wide_vector.hpp => wide_vector.hpp} | 0 include/mbgl/shaders/shader_manifest.hpp | 53 +- include/mbgl/shaders/shader_source.hpp | 31 +- shaders/background.fragment.glsl | 10 +- shaders/background.vertex.glsl | 4 +- shaders/background_pattern.fragment.glsl | 39 +- shaders/background_pattern.vertex.glsl | 34 +- shaders/circle.fragment.glsl | 13 + shaders/circle.vertex.glsl | 50 +- shaders/collision_box.fragment.glsl | 1 - shaders/collision_box.vertex.glsl | 24 +- shaders/collision_circle.fragment.glsl | 18 +- shaders/collision_circle.vertex.glsl | 24 +- ....glsl => custom.symbol_icon.fragment.glsl} | 0 ...ex.glsl => custom.symbol_icon.vertex.glsl} | 0 ...ent.glsl => custom_geometry.fragment.glsl} | 0 ...ertex.glsl => custom_geometry.vertex.glsl} | 0 shaders/debug.fragment.glsl | 10 +- shaders/debug.vertex.glsl | 10 +- shaders/drawable.background.fragment.glsl | 14 - shaders/drawable.background.vertex.glsl | 8 - .../drawable.background_pattern.fragment.glsl | 45 -- .../drawable.background_pattern.vertex.glsl | 33 -- shaders/drawable.circle.fragment.glsl | 52 -- shaders/drawable.circle.vertex.glsl | 97 --- shaders/drawable.collision_box.fragment.glsl | 20 - shaders/drawable.collision_box.vertex.glsl | 45 -- .../drawable.collision_circle.fragment.glsl | 50 -- shaders/drawable.collision_circle.vertex.glsl | 53 -- shaders/drawable.debug.fragment.glsl | 17 - shaders/drawable.debug.vertex.glsl | 18 - shaders/drawable.fill.fragment.glsl | 22 - shaders/drawable.fill.vertex.glsl | 29 - shaders/drawable.fill_extrusion.fragment.glsl | 9 - shaders/drawable.fill_extrusion.vertex.glsl | 96 --- ...wable.fill_extrusion_pattern.fragment.glsl | 62 -- ...rawable.fill_extrusion_pattern.vertex.glsl | 115 ---- shaders/drawable.fill_outline.fragment.glsl | 26 - shaders/drawable.fill_outline.vertex.glsl | 44 -- ...rawable.fill_outline_pattern.fragment.glsl | 57 -- .../drawable.fill_outline_pattern.vertex.glsl | 75 --- shaders/drawable.fill_pattern.fragment.glsl | 54 -- shaders/drawable.fill_pattern.vertex.glsl | 71 --- shaders/drawable.heatmap.fragment.glsl | 27 - shaders/drawable.heatmap.vertex.glsl | 63 -- .../drawable.heatmap_texture.fragment.glsl | 21 - shaders/drawable.heatmap_texture.vertex.glsl | 29 - shaders/drawable.hillshade.fragment.glsl | 57 -- shaders/drawable.hillshade.vertex.glsl | 13 - .../drawable.hillshade_prepare.fragment.glsl | 77 --- .../drawable.hillshade_prepare.vertex.glsl | 23 - shaders/drawable.line.fragment.glsl | 40 -- shaders/drawable.line.vertex.glsl | 117 ---- shaders/drawable.line_gradient.fragment.glsl | 45 -- shaders/drawable.line_gradient.vertex.glsl | 119 ---- shaders/drawable.line_pattern.fragment.glsl | 86 --- shaders/drawable.line_pattern.vertex.glsl | 131 ----- shaders/drawable.line_sdf.fragment.glsl | 60 -- shaders/drawable.line_sdf.vertex.glsl | 132 ----- shaders/drawable.raster.fragment.glsl | 58 -- shaders/drawable.raster.vertex.glsl | 34 -- shaders/drawable.symbol_icon.fragment.glsl | 41 -- shaders/drawable.symbol_icon.vertex.glsl | 127 ---- shaders/drawable.symbol_sdf.fragment.glsl | 76 --- shaders/drawable.symbol_sdf.vertex.glsl | 156 ----- ...rawable.symbol_text_and_icon.fragment.glsl | 93 --- .../drawable.symbol_text_and_icon.vertex.glsl | 156 ----- shaders/fill.fragment.glsl | 9 + shaders/fill.vertex.glsl | 20 +- shaders/fill_extrusion.vertex.glsl | 46 +- shaders/fill_extrusion_pattern.fragment.glsl | 31 +- shaders/fill_extrusion_pattern.vertex.glsl | 71 ++- shaders/fill_outline.fragment.glsl | 9 + shaders/fill_outline.vertex.glsl | 35 +- shaders/fill_outline_pattern.fragment.glsl | 22 +- shaders/fill_outline_pattern.vertex.glsl | 58 +- ...> fill_outline_triangulated.fragment.glsl} | 0 ... => fill_outline_triangulated.vertex.glsl} | 0 shaders/fill_pattern.fragment.glsl | 26 +- shaders/fill_pattern.vertex.glsl | 55 +- shaders/heatmap.fragment.glsl | 9 +- shaders/heatmap.vertex.glsl | 21 +- shaders/heatmap_texture.fragment.glsl | 11 +- shaders/heatmap_texture.vertex.glsl | 24 +- shaders/hillshade.fragment.glsl | 17 +- shaders/hillshade.vertex.glsl | 6 +- shaders/hillshade_prepare.fragment.glsl | 13 +- shaders/hillshade_prepare.vertex.glsl | 14 +- shaders/line.fragment.glsl | 14 +- shaders/line.vertex.glsl | 42 +- shaders/line_gradient.fragment.glsl | 15 +- shaders/line_gradient.vertex.glsl | 42 +- shaders/line_pattern.fragment.glsl | 31 +- shaders/line_pattern.vertex.glsl | 54 +- shaders/line_sdf.fragment.glsl | 23 +- shaders/line_sdf.vertex.glsl | 52 +- ....glsl => location_indicator.fragment.glsl} | 0 ...ex.glsl => location_indicator.vertex.glsl} | 0 ...location_indicator_textured.fragment.glsl} | 0 ...> location_indicator_textured.vertex.glsl} | 0 shaders/manifest.json | 473 +++++---------- shaders/raster.fragment.glsl | 24 +- shaders/raster.vertex.glsl | 21 +- shaders/symbol_icon.fragment.glsl | 24 + shaders/symbol_icon.vertex.glsl | 69 ++- shaders/symbol_sdf.fragment.glsl | 34 +- shaders/symbol_sdf.vertex.glsl | 77 ++- shaders/symbol_text_and_icon.fragment.glsl | 33 +- shaders/symbol_text_and_icon.vertex.glsl | 76 ++- src/mbgl/gfx/drawable_builder_impl.cpp | 4 +- src/mbgl/gfx/fill_generator.cpp | 42 +- src/mbgl/gfx/polyline_generator.cpp | 4 +- src/mbgl/layout/circle_layout.hpp | 8 +- src/mbgl/layout/symbol_layout.cpp | 86 +-- src/mbgl/layout/symbol_projection.cpp | 2 +- src/mbgl/layout/symbol_projection.hpp | 2 +- .../programs/background_pattern_program.hpp | 4 - src/mbgl/programs/background_program.cpp | 48 -- src/mbgl/programs/background_program.hpp | 79 --- src/mbgl/programs/circle_program.cpp | 7 - src/mbgl/programs/circle_program.hpp | 48 -- src/mbgl/programs/collision_box_program.cpp | 7 - src/mbgl/programs/collision_box_program.hpp | 168 ------ .../programs/collision_circle_program.hpp | 4 - src/mbgl/programs/debug_program.cpp | 3 - src/mbgl/programs/debug_program.hpp | 31 - .../fill_extrusion_pattern_program.hpp | 4 - src/mbgl/programs/fill_extrusion_program.cpp | 80 --- src/mbgl/programs/fill_extrusion_program.hpp | 118 ---- .../programs/fill_outline_pattern_program.hpp | 4 - src/mbgl/programs/fill_outline_program.hpp | 4 - src/mbgl/programs/fill_pattern_program.hpp | 4 - src/mbgl/programs/fill_program.cpp | 37 -- src/mbgl/programs/fill_program.hpp | 103 ---- src/mbgl/programs/heatmap_program.cpp | 7 - src/mbgl/programs/heatmap_program.hpp | 45 -- src/mbgl/programs/heatmap_texture_program.cpp | 7 - src/mbgl/programs/heatmap_texture_program.hpp | 31 - .../programs/hillshade_prepare_program.cpp | 7 - .../programs/hillshade_prepare_program.hpp | 40 -- src/mbgl/programs/hillshade_program.cpp | 7 - src/mbgl/programs/hillshade_program.hpp | 47 -- src/mbgl/programs/line_gradient_program.hpp | 4 - src/mbgl/programs/line_pattern_program.hpp | 4 - src/mbgl/programs/line_program.cpp | 101 ---- src/mbgl/programs/line_program.hpp | 180 ------ src/mbgl/programs/line_sdf_program.hpp | 4 - src/mbgl/programs/program.hpp | 4 +- src/mbgl/programs/programs.cpp | 11 +- src/mbgl/programs/programs.hpp | 12 - src/mbgl/programs/raster_program.cpp | 7 - src/mbgl/programs/raster_program.hpp | 55 -- src/mbgl/programs/segment.hpp | 8 +- src/mbgl/programs/symbol_icon_program.hpp | 4 - src/mbgl/programs/symbol_program.cpp | 175 ------ src/mbgl/programs/symbol_program.hpp | 551 ------------------ src/mbgl/programs/symbol_sdf_icon_program.hpp | 4 - src/mbgl/programs/symbol_sdf_text_program.hpp | 4 - .../programs/symbol_text_and_icon_program.hpp | 4 - src/mbgl/renderer/buckets/circle_bucket.cpp | 3 +- src/mbgl/renderer/buckets/circle_bucket.hpp | 20 +- src/mbgl/renderer/buckets/debug_bucket.cpp | 2 +- src/mbgl/renderer/buckets/debug_bucket.hpp | 11 +- src/mbgl/renderer/buckets/fill_bucket.cpp | 1 - src/mbgl/renderer/buckets/fill_bucket.hpp | 17 +- .../buckets/fill_extrusion_bucket.cpp | 32 +- .../buckets/fill_extrusion_bucket.hpp | 29 +- src/mbgl/renderer/buckets/heatmap_bucket.cpp | 9 +- src/mbgl/renderer/buckets/heatmap_bucket.hpp | 25 +- .../renderer/buckets/hillshade_bucket.cpp | 10 +- .../renderer/buckets/hillshade_bucket.hpp | 16 +- src/mbgl/renderer/buckets/line_bucket.cpp | 12 +- src/mbgl/renderer/buckets/line_bucket.hpp | 49 +- src/mbgl/renderer/buckets/raster_bucket.cpp | 9 +- src/mbgl/renderer/buckets/raster_bucket.hpp | 13 +- src/mbgl/renderer/buckets/symbol_bucket.cpp | 21 + src/mbgl/renderer/buckets/symbol_bucket.hpp | 219 ++++++- .../renderer/layers/circle_layer_tweaker.cpp | 4 +- .../layers/fill_extrusion_layer_tweaker.cpp | 10 +- .../renderer/layers/fill_layer_tweaker.cpp | 2 +- .../renderer/layers/heatmap_layer_tweaker.cpp | 3 +- .../renderer/layers/line_layer_tweaker.cpp | 4 +- .../layers/render_background_layer.hpp | 4 +- .../renderer/layers/render_circle_layer.cpp | 1 - .../layers/render_fill_extrusion_layer.cpp | 1 - .../renderer/layers/render_fill_layer.cpp | 1 - .../renderer/layers/render_fill_layer.hpp | 6 - .../renderer/layers/render_heatmap_layer.hpp | 4 +- .../layers/render_hillshade_layer.hpp | 3 +- .../renderer/layers/render_line_layer.cpp | 1 - .../renderer/layers/render_raster_layer.cpp | 1 - .../renderer/layers/render_raster_layer.hpp | 5 +- .../renderer/layers/render_symbol_layer.cpp | 8 +- .../renderer/layers/render_symbol_layer.hpp | 17 - .../renderer/layers/symbol_layer_tweaker.cpp | 5 +- src/mbgl/renderer/render_static_data.cpp | 32 +- src/mbgl/renderer/render_static_data.hpp | 15 +- src/mbgl/renderer/render_tile.cpp | 85 --- src/mbgl/renderer/render_tile.hpp | 1 - .../renderer/sources/render_image_source.cpp | 45 +- .../renderer/sources/render_image_source.hpp | 2 +- .../renderer/sources/render_tile_source.cpp | 6 - .../renderer/sources/render_tile_source.hpp | 2 +- .../style/layers/custom_drawable_layer.cpp | 11 +- src/mbgl/text/placement.cpp | 16 +- test/CMakeLists.txt | 1 - test/gl/bucket.test.cpp | 75 ++- test/programs/symbol_program.test.cpp | 65 --- test/renderer/shader_registry.test.cpp | 9 +- test/tile/vector_tile.test.cpp | 1 + 267 files changed, 3053 insertions(+), 10896 deletions(-) rename include/mbgl/shaders/gl/{drawable_custom_geometry.hpp => custom_geometry.hpp} (98%) rename include/mbgl/shaders/gl/{drawable_custom_symbol_icon.hpp => custom_symbol_icon.hpp} (100%) delete mode 100644 include/mbgl/shaders/gl/drawable_background.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_background_pattern.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_circle.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_collision_box.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_collision_circle.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_debug.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_fill.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_fill_extrusion.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_fill_outline.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_fill_pattern.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_heatmap.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_heatmap_texture.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_hillshade.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_line.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_line_gradient.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_line_pattern.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_line_sdf.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_raster.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_symbol_icon.hpp delete mode 100644 include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp rename include/mbgl/shaders/gl/{drawable_fill_outline_triangulated.hpp => fill_outline_triangulated.hpp} (100%) rename include/mbgl/shaders/gl/{drawable_location_indicator.hpp => location_indicator.hpp} (98%) rename include/mbgl/shaders/gl/{drawable_location_indicator_textured.hpp => location_indicator_textured.hpp} (98%) rename include/mbgl/shaders/gl/{drawable_symbol_sdf.hpp => symbol_sdf.hpp} (100%) delete mode 100644 include/mbgl/shaders/gl/symbol_sdf_icon.hpp delete mode 100644 include/mbgl/shaders/gl/symbol_sdf_text.hpp rename include/mbgl/shaders/gl/{drawable_wide_vector.hpp => wide_vector.hpp} (100%) rename shaders/{drawable.custom.symbol_icon.fragment.glsl => custom.symbol_icon.fragment.glsl} (100%) rename shaders/{drawable.custom.symbol_icon.vertex.glsl => custom.symbol_icon.vertex.glsl} (100%) rename shaders/{drawable.custom_geometry.fragment.glsl => custom_geometry.fragment.glsl} (100%) rename shaders/{drawable.custom_geometry.vertex.glsl => custom_geometry.vertex.glsl} (100%) delete mode 100644 shaders/drawable.background.fragment.glsl delete mode 100644 shaders/drawable.background.vertex.glsl delete mode 100644 shaders/drawable.background_pattern.fragment.glsl delete mode 100644 shaders/drawable.background_pattern.vertex.glsl delete mode 100644 shaders/drawable.circle.fragment.glsl delete mode 100644 shaders/drawable.circle.vertex.glsl delete mode 100644 shaders/drawable.collision_box.fragment.glsl delete mode 100644 shaders/drawable.collision_box.vertex.glsl delete mode 100644 shaders/drawable.collision_circle.fragment.glsl delete mode 100644 shaders/drawable.collision_circle.vertex.glsl delete mode 100644 shaders/drawable.debug.fragment.glsl delete mode 100644 shaders/drawable.debug.vertex.glsl delete mode 100644 shaders/drawable.fill.fragment.glsl delete mode 100644 shaders/drawable.fill.vertex.glsl delete mode 100644 shaders/drawable.fill_extrusion.fragment.glsl delete mode 100644 shaders/drawable.fill_extrusion.vertex.glsl delete mode 100644 shaders/drawable.fill_extrusion_pattern.fragment.glsl delete mode 100644 shaders/drawable.fill_extrusion_pattern.vertex.glsl delete mode 100644 shaders/drawable.fill_outline.fragment.glsl delete mode 100644 shaders/drawable.fill_outline.vertex.glsl delete mode 100644 shaders/drawable.fill_outline_pattern.fragment.glsl delete mode 100644 shaders/drawable.fill_outline_pattern.vertex.glsl delete mode 100644 shaders/drawable.fill_pattern.fragment.glsl delete mode 100644 shaders/drawable.fill_pattern.vertex.glsl delete mode 100644 shaders/drawable.heatmap.fragment.glsl delete mode 100644 shaders/drawable.heatmap.vertex.glsl delete mode 100644 shaders/drawable.heatmap_texture.fragment.glsl delete mode 100644 shaders/drawable.heatmap_texture.vertex.glsl delete mode 100644 shaders/drawable.hillshade.fragment.glsl delete mode 100644 shaders/drawable.hillshade.vertex.glsl delete mode 100644 shaders/drawable.hillshade_prepare.fragment.glsl delete mode 100644 shaders/drawable.hillshade_prepare.vertex.glsl delete mode 100644 shaders/drawable.line.fragment.glsl delete mode 100644 shaders/drawable.line.vertex.glsl delete mode 100644 shaders/drawable.line_gradient.fragment.glsl delete mode 100644 shaders/drawable.line_gradient.vertex.glsl delete mode 100644 shaders/drawable.line_pattern.fragment.glsl delete mode 100644 shaders/drawable.line_pattern.vertex.glsl delete mode 100644 shaders/drawable.line_sdf.fragment.glsl delete mode 100644 shaders/drawable.line_sdf.vertex.glsl delete mode 100644 shaders/drawable.raster.fragment.glsl delete mode 100644 shaders/drawable.raster.vertex.glsl delete mode 100644 shaders/drawable.symbol_icon.fragment.glsl delete mode 100644 shaders/drawable.symbol_icon.vertex.glsl delete mode 100644 shaders/drawable.symbol_sdf.fragment.glsl delete mode 100644 shaders/drawable.symbol_sdf.vertex.glsl delete mode 100644 shaders/drawable.symbol_text_and_icon.fragment.glsl delete mode 100644 shaders/drawable.symbol_text_and_icon.vertex.glsl rename shaders/{drawable.fill_outline_triangulated.fragment.glsl => fill_outline_triangulated.fragment.glsl} (100%) rename shaders/{drawable.fill_outline_triangulated.vertex.glsl => fill_outline_triangulated.vertex.glsl} (100%) rename shaders/{drawable.location_indicator.fragment.glsl => location_indicator.fragment.glsl} (100%) rename shaders/{drawable.location_indicator.vertex.glsl => location_indicator.vertex.glsl} (100%) rename shaders/{drawable.location_indicator_textured.fragment.glsl => location_indicator_textured.fragment.glsl} (100%) rename shaders/{drawable.location_indicator_textured.vertex.glsl => location_indicator_textured.vertex.glsl} (100%) delete mode 100644 src/mbgl/programs/background_pattern_program.hpp delete mode 100644 src/mbgl/programs/background_program.cpp delete mode 100644 src/mbgl/programs/background_program.hpp delete mode 100644 src/mbgl/programs/circle_program.cpp delete mode 100644 src/mbgl/programs/circle_program.hpp delete mode 100644 src/mbgl/programs/collision_box_program.cpp delete mode 100644 src/mbgl/programs/collision_box_program.hpp delete mode 100644 src/mbgl/programs/collision_circle_program.hpp delete mode 100644 src/mbgl/programs/debug_program.cpp delete mode 100644 src/mbgl/programs/debug_program.hpp delete mode 100644 src/mbgl/programs/fill_extrusion_pattern_program.hpp delete mode 100644 src/mbgl/programs/fill_extrusion_program.cpp delete mode 100644 src/mbgl/programs/fill_extrusion_program.hpp delete mode 100644 src/mbgl/programs/fill_outline_pattern_program.hpp delete mode 100644 src/mbgl/programs/fill_outline_program.hpp delete mode 100644 src/mbgl/programs/fill_pattern_program.hpp delete mode 100644 src/mbgl/programs/fill_program.cpp delete mode 100644 src/mbgl/programs/fill_program.hpp delete mode 100644 src/mbgl/programs/heatmap_program.cpp delete mode 100644 src/mbgl/programs/heatmap_program.hpp delete mode 100644 src/mbgl/programs/heatmap_texture_program.cpp delete mode 100644 src/mbgl/programs/heatmap_texture_program.hpp delete mode 100644 src/mbgl/programs/hillshade_prepare_program.cpp delete mode 100644 src/mbgl/programs/hillshade_prepare_program.hpp delete mode 100644 src/mbgl/programs/hillshade_program.cpp delete mode 100644 src/mbgl/programs/hillshade_program.hpp delete mode 100644 src/mbgl/programs/line_gradient_program.hpp delete mode 100644 src/mbgl/programs/line_pattern_program.hpp delete mode 100644 src/mbgl/programs/line_program.cpp delete mode 100644 src/mbgl/programs/line_program.hpp delete mode 100644 src/mbgl/programs/line_sdf_program.hpp delete mode 100644 src/mbgl/programs/raster_program.cpp delete mode 100644 src/mbgl/programs/raster_program.hpp delete mode 100644 src/mbgl/programs/symbol_icon_program.hpp delete mode 100644 src/mbgl/programs/symbol_program.cpp delete mode 100644 src/mbgl/programs/symbol_program.hpp delete mode 100644 src/mbgl/programs/symbol_sdf_icon_program.hpp delete mode 100644 src/mbgl/programs/symbol_sdf_text_program.hpp delete mode 100644 src/mbgl/programs/symbol_text_and_icon_program.hpp delete mode 100644 test/programs/symbol_program.test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b47c67564..aefcb6d16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -544,53 +544,14 @@ list(APPEND SRC_FILES ${PROJECT_SOURCE_DIR}/src/mbgl/math/log2.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/platform/settings.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/attributes.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/background_pattern_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/background_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/background_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/circle_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/circle_program.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/clipping_mask_program.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/clipping_mask_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/collision_box_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/collision_box_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/collision_circle_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/debug_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/debug_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_extrusion_pattern_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_extrusion_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_extrusion_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_outline_pattern_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_outline_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_pattern_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/fill_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/heatmap_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/heatmap_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/heatmap_texture_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/heatmap_texture_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/hillshade_prepare_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/hillshade_prepare_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/hillshade_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/hillshade_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/line_gradient_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/line_pattern_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/line_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/line_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/line_sdf_program.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/program.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/program_parameters.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/program_parameters.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/programs.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/programs.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/raster_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/raster_program.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/segment.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/symbol_icon_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/symbol_program.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/symbol_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/symbol_sdf_icon_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/symbol_sdf_text_program.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/symbol_text_and_icon_program.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/textures.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/programs/uniforms.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/backend_scope.cpp @@ -1024,61 +985,36 @@ if(MLN_WITH_OPENGL) ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/shader_group_gl.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/prelude.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/background.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_background.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_background_pattern.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_circle.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_box.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_circle.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_custom_geometry.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_debug.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_pattern.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline_triangulated.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_heatmap.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_hillshade.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_gradient.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_pattern.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_sdf.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_location_indicator.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_raster.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_icon.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_wide_vector.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/background_pattern.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/circle.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/clipping_mask.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/collision_box.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/collision_circle.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/custom_geometry.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/custom_symbol_icon.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/debug.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_extrusion.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_outline_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_outline.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_pattern.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/heatmap_texture.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_outline_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_outline_triangulated.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_extrusion.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/heatmap.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/heatmap_texture.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/hillshade_prepare.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/hillshade.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line_gradient.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line_pattern.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line_sdf.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/location_indicator.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/location_indicator_textured.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/raster.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_icon.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_sdf_icon.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_sdf_text.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_sdf.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_text_and_icon.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/wide_vector.hpp ) list(APPEND SRC_FILES diff --git a/bazel/core.bzl b/bazel/core.bzl index 80ea58fee..06efec4e3 100644 --- a/bazel/core.bzl +++ b/bazel/core.bzl @@ -61,57 +61,32 @@ MLN_GENERATED_OPENGL_SHADER_HEADERS = [ "include/mbgl/shaders/gl/clipping_mask.hpp", "include/mbgl/shaders/gl/collision_box.hpp", "include/mbgl/shaders/gl/collision_circle.hpp", + "include/mbgl/shaders/gl/custom_geometry.hpp", + "include/mbgl/shaders/gl/custom_symbol_icon.hpp", "include/mbgl/shaders/gl/debug.hpp", - "include/mbgl/shaders/gl/drawable_background.hpp", - "include/mbgl/shaders/gl/drawable_background_pattern.hpp", - "include/mbgl/shaders/gl/drawable_circle.hpp", - "include/mbgl/shaders/gl/drawable_collision_box.hpp", - "include/mbgl/shaders/gl/drawable_collision_circle.hpp", - "include/mbgl/shaders/gl/drawable_custom_geometry.hpp", - "include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp", - "include/mbgl/shaders/gl/drawable_debug.hpp", - "include/mbgl/shaders/gl/drawable_fill.hpp", - "include/mbgl/shaders/gl/drawable_fill_outline.hpp", - "include/mbgl/shaders/gl/drawable_fill_pattern.hpp", - "include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp", - "include/mbgl/shaders/gl/drawable_fill_outline_triangulated.hpp", - "include/mbgl/shaders/gl/drawable_fill_extrusion.hpp", - "include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp", - "include/mbgl/shaders/gl/drawable_heatmap.hpp", - "include/mbgl/shaders/gl/drawable_heatmap_texture.hpp", - "include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp", - "include/mbgl/shaders/gl/drawable_hillshade.hpp", - "include/mbgl/shaders/gl/drawable_line_gradient.hpp", - "include/mbgl/shaders/gl/drawable_line_pattern.hpp", - "include/mbgl/shaders/gl/drawable_line_sdf.hpp", - "include/mbgl/shaders/gl/drawable_line.hpp", - "include/mbgl/shaders/gl/drawable_location_indicator.hpp", - "include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp", - "include/mbgl/shaders/gl/drawable_raster.hpp", - "include/mbgl/shaders/gl/drawable_symbol_icon.hpp", - "include/mbgl/shaders/gl/drawable_symbol_sdf.hpp", - "include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp", - "include/mbgl/shaders/gl/drawable_wide_vector.hpp", - "include/mbgl/shaders/gl/fill_extrusion_pattern.hpp", - "include/mbgl/shaders/gl/fill_extrusion.hpp", - "include/mbgl/shaders/gl/fill_outline_pattern.hpp", + "include/mbgl/shaders/gl/fill.hpp", "include/mbgl/shaders/gl/fill_outline.hpp", "include/mbgl/shaders/gl/fill_pattern.hpp", - "include/mbgl/shaders/gl/fill.hpp", - "include/mbgl/shaders/gl/heatmap_texture.hpp", + "include/mbgl/shaders/gl/fill_outline_pattern.hpp", + "include/mbgl/shaders/gl/fill_outline_triangulated.hpp", + "include/mbgl/shaders/gl/fill_extrusion.hpp", + "include/mbgl/shaders/gl/fill_extrusion_pattern.hpp", "include/mbgl/shaders/gl/heatmap.hpp", + "include/mbgl/shaders/gl/heatmap_texture.hpp", "include/mbgl/shaders/gl/hillshade_prepare.hpp", "include/mbgl/shaders/gl/hillshade.hpp", "include/mbgl/shaders/gl/line_gradient.hpp", "include/mbgl/shaders/gl/line_pattern.hpp", "include/mbgl/shaders/gl/line_sdf.hpp", "include/mbgl/shaders/gl/line.hpp", - "include/mbgl/shaders/gl/prelude.hpp", + "include/mbgl/shaders/gl/location_indicator.hpp", + "include/mbgl/shaders/gl/location_indicator_textured.hpp", "include/mbgl/shaders/gl/raster.hpp", "include/mbgl/shaders/gl/symbol_icon.hpp", - "include/mbgl/shaders/gl/symbol_sdf_text.hpp", - "include/mbgl/shaders/gl/symbol_sdf_icon.hpp", + "include/mbgl/shaders/gl/symbol_sdf.hpp", "include/mbgl/shaders/gl/symbol_text_and_icon.hpp", + "include/mbgl/shaders/gl/wide_vector.hpp", + "include/mbgl/shaders/gl/prelude.hpp", ] MLN_CORE_SOURCE = [ @@ -210,53 +185,14 @@ MLN_CORE_SOURCE = [ "src/mbgl/math/log2.cpp", "src/mbgl/platform/settings.cpp", "src/mbgl/programs/attributes.hpp", - "src/mbgl/programs/background_pattern_program.hpp", - "src/mbgl/programs/background_program.cpp", - "src/mbgl/programs/background_program.hpp", - "src/mbgl/programs/circle_program.cpp", - "src/mbgl/programs/circle_program.hpp", "src/mbgl/programs/clipping_mask_program.cpp", "src/mbgl/programs/clipping_mask_program.hpp", - "src/mbgl/programs/collision_box_program.cpp", - "src/mbgl/programs/collision_box_program.hpp", - "src/mbgl/programs/collision_circle_program.hpp", - "src/mbgl/programs/debug_program.cpp", - "src/mbgl/programs/debug_program.hpp", - "src/mbgl/programs/fill_extrusion_pattern_program.hpp", - "src/mbgl/programs/fill_extrusion_program.cpp", - "src/mbgl/programs/fill_extrusion_program.hpp", - "src/mbgl/programs/fill_outline_pattern_program.hpp", - "src/mbgl/programs/fill_outline_program.hpp", - "src/mbgl/programs/fill_pattern_program.hpp", - "src/mbgl/programs/fill_program.cpp", - "src/mbgl/programs/fill_program.hpp", - "src/mbgl/programs/heatmap_program.cpp", - "src/mbgl/programs/heatmap_program.hpp", - "src/mbgl/programs/heatmap_texture_program.cpp", - "src/mbgl/programs/heatmap_texture_program.hpp", - "src/mbgl/programs/hillshade_prepare_program.cpp", - "src/mbgl/programs/hillshade_prepare_program.hpp", - "src/mbgl/programs/hillshade_program.cpp", - "src/mbgl/programs/hillshade_program.hpp", - "src/mbgl/programs/line_gradient_program.hpp", - "src/mbgl/programs/line_pattern_program.hpp", - "src/mbgl/programs/line_program.cpp", - "src/mbgl/programs/line_program.hpp", - "src/mbgl/programs/line_sdf_program.hpp", "src/mbgl/programs/program.hpp", "src/mbgl/programs/program_parameters.cpp", "src/mbgl/programs/program_parameters.hpp", "src/mbgl/programs/programs.cpp", "src/mbgl/programs/programs.hpp", - "src/mbgl/programs/raster_program.cpp", - "src/mbgl/programs/raster_program.hpp", "src/mbgl/programs/segment.hpp", - "src/mbgl/programs/symbol_icon_program.hpp", - "src/mbgl/programs/symbol_program.cpp", - "src/mbgl/programs/symbol_program.hpp", - "src/mbgl/programs/symbol_sdf_icon_program.hpp", - "src/mbgl/programs/symbol_sdf_text_program.hpp", - "src/mbgl/programs/symbol_text_and_icon_program.hpp", "src/mbgl/programs/textures.hpp", "src/mbgl/programs/uniforms.hpp", "src/mbgl/renderer/backend_scope.cpp", diff --git a/include/mbgl/gfx/fill_generator.hpp b/include/mbgl/gfx/fill_generator.hpp index 6766cf112..fed717ca6 100644 --- a/include/mbgl/gfx/fill_generator.hpp +++ b/include/mbgl/gfx/fill_generator.hpp @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include namespace mbgl { namespace gfx { @@ -14,35 +14,35 @@ namespace gfx { void generateFillBuffers(const GeometryCollection& geometry, gfx::VertexVector& fillVertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments); + SegmentVector& fillSegments); /// Generate fill and outline buffers, with the outline composed of line primitives. void generateFillAndOutineBuffers(const GeometryCollection& geometry, gfx::VertexVector& vertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments, + SegmentVector& fillSegments, gfx::IndexVector& lineIndexes, - SegmentVector& lineSegments); + SegmentVector& lineSegments); /// Generate fill and outline buffers, where the outlines are built with triangle primitives void generateFillAndOutineBuffers(const GeometryCollection& geometry, gfx::VertexVector& fillVertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments, + SegmentVector& fillSegments, gfx::VertexVector& lineVertices, gfx::IndexVector& lineIndexes, - SegmentVector& lineSegments); + SegmentVector& lineSegments); /// Generate fill and outline buffers, where the outlines are built both with triangle primitives AND with simple lines void generateFillAndOutineBuffers(const GeometryCollection& geometry, gfx::VertexVector& fillVertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments, + SegmentVector& fillSegments, gfx::VertexVector& lineVertices, gfx::IndexVector& lineIndexes, - SegmentVector& lineSegments, + SegmentVector& lineSegments, gfx::IndexVector& basicLineIndexes, - SegmentVector& basicLineSegments); + SegmentVector& basicLineSegments); } // namespace gfx } // namespace mbgl diff --git a/include/mbgl/shaders/gl/background.hpp b/include/mbgl/shaders/gl/background.hpp index cfc19d792..9e7e233a1 100644 --- a/include/mbgl/shaders/gl/background.hpp +++ b/include/mbgl/shaders/gl/background.hpp @@ -6,21 +6,27 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "BackgroundProgram"; +struct ShaderSource { + static constexpr const char* name = "BackgroundShader"; static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -uniform mat4 u_matrix; +layout (std140) uniform BackgroundDrawableUBO { + highp mat4 u_matrix; +}; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); } )"; - static constexpr const char* fragment = R"(uniform vec4 u_color; -uniform float u_opacity; + static constexpr const char* fragment = R"(layout (std140) uniform BackgroundPropsUBO { + highp vec4 u_color; + highp float u_opacity; + lowp float props_pad1; + lowp float props_pad2; + lowp float props_pad3; +}; void main() { fragColor = u_color * u_opacity; - #ifdef OVERDRAW_INSPECTOR fragColor = vec4(1.0); #endif diff --git a/include/mbgl/shaders/gl/background_pattern.hpp b/include/mbgl/shaders/gl/background_pattern.hpp index bb6dd5968..94cacec93 100644 --- a/include/mbgl/shaders/gl/background_pattern.hpp +++ b/include/mbgl/shaders/gl/background_pattern.hpp @@ -6,20 +6,34 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "BackgroundPatternProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec2 u_pattern_size_a; -uniform vec2 u_pattern_size_b; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform float u_scale_a; -uniform float u_scale_b; -uniform float u_tile_units_to_pixels; +struct ShaderSource { + static constexpr const char* name = "BackgroundPatternShader"; + static constexpr const char* vertex = R"(layout (std140) uniform BackgroundPatternDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_tile_units_to_pixels; + lowp float drawable_pad1; + lowp float drawable_pad2; + lowp float drawable_pad3; +}; + +layout (std140) uniform BackgroundPatternPropsUBO { + highp vec2 u_pattern_tl_a; + highp vec2 u_pattern_br_a; + highp vec2 u_pattern_tl_b; + highp vec2 u_pattern_br_b; + highp vec2 u_pattern_size_a; + highp vec2 u_pattern_size_b; + highp float u_scale_a; + highp float u_scale_b; + highp float u_mix; + highp float u_opacity; +}; layout (location = 0) in vec2 a_pos; -out vec2 v_pos_a; -out vec2 v_pos_b; +out mediump vec2 v_pos_a; +out mediump vec2 v_pos_b; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); @@ -28,26 +42,43 @@ void main() { v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos); } )"; - static constexpr const char* fragment = R"(uniform vec2 u_pattern_tl_a; -uniform vec2 u_pattern_br_a; -uniform vec2 u_pattern_tl_b; -uniform vec2 u_pattern_br_b; -uniform vec2 u_texsize; -uniform float u_mix; -uniform float u_opacity; + static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform BackgroundPatternPropsUBO { + highp vec2 u_pattern_tl_a; + highp vec2 u_pattern_br_a; + highp vec2 u_pattern_tl_b; + highp vec2 u_pattern_br_b; + highp vec2 u_pattern_size_a; + highp vec2 u_pattern_size_b; + highp float u_scale_a; + highp float u_scale_b; + highp float u_mix; + highp float u_opacity; +}; uniform sampler2D u_image; -in vec2 v_pos_a; -in vec2 v_pos_b; +in mediump vec2 v_pos_a; +in mediump vec2 v_pos_b; void main() { vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord); + vec2 pos = mix(u_pattern_tl_a / u_pattern_atlas_texsize, u_pattern_br_a / u_pattern_atlas_texsize, imagecoord); vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b); + vec2 pos2 = mix(u_pattern_tl_b / u_pattern_atlas_texsize, u_pattern_br_b / u_pattern_atlas_texsize, imagecoord_b); vec4 color2 = texture(u_image, pos2); fragColor = mix(color1, color2, u_mix) * u_opacity; diff --git a/include/mbgl/shaders/gl/circle.hpp b/include/mbgl/shaders/gl/circle.hpp index f02c02589..54b0ab20d 100644 --- a/include/mbgl/shaders/gl/circle.hpp +++ b/include/mbgl/shaders/gl/circle.hpp @@ -6,66 +6,79 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "CircleProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform bool u_scale_with_map; -uniform bool u_pitch_with_map; -uniform vec2 u_extrude_scale; -uniform lowp float u_device_pixel_ratio; -uniform highp float u_camera_to_center_distance; - -layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "CircleShader"; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; out vec3 v_data; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CircleDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_extrude_scale; + // Interpolations + lowp float u_color_t; + lowp float u_radius_t; + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_stroke_color_t; + lowp float u_stroke_width_t; + lowp float u_stroke_opacity_t; + lowp float drawable_pad1; + lowp float drawable_pad2; + lowp float drawable_pad3; +}; + +layout (std140) uniform CircleEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_stroke_color; + mediump float u_radius; + lowp float u_blur; + lowp float u_opacity; + mediump float u_stroke_width; + lowp float u_stroke_opacity; + bool u_scale_with_map; + bool u_pitch_with_map; + lowp float props_pad1; +}; + #ifndef HAS_UNIFORM_u_color -uniform lowp float u_color_t; layout (location = 1) in highp vec4 a_color; out highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_radius -uniform lowp float u_radius_t; layout (location = 2) in mediump vec2 a_radius; out mediump float radius; -#else -uniform mediump float u_radius; #endif #ifndef HAS_UNIFORM_u_blur -uniform lowp float u_blur_t; layout (location = 3) in lowp vec2 a_blur; out lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 4) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_stroke_color -uniform lowp float u_stroke_color_t; layout (location = 5) in highp vec4 a_stroke_color; out highp vec4 stroke_color; -#else -uniform highp vec4 u_stroke_color; #endif #ifndef HAS_UNIFORM_u_stroke_width -uniform lowp float u_stroke_width_t; layout (location = 6) in mediump vec2 a_stroke_width; out mediump float stroke_width; -#else -uniform mediump float u_stroke_width; #endif #ifndef HAS_UNIFORM_u_stroke_opacity -uniform lowp float u_stroke_opacity_t; layout (location = 7) in lowp vec2 a_stroke_opacity; out lowp float stroke_opacity; -#else -uniform lowp float u_stroke_opacity; #endif void main(void) { @@ -137,47 +150,46 @@ lowp float stroke_opacity = u_stroke_opacity; // This is a minimum blur distance that serves as a faux-antialiasing for // the circle. since blur is a ratio of the circle's size and the intent is // to keep the blur at roughly 1px, the two are inversely related. - lowp float antialiasblur = 1.0 / u_device_pixel_ratio / (radius + stroke_width); + lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width); v_data = vec3(extrude.x, extrude.y, antialiasblur); } )"; static constexpr const char* fragment = R"(in vec3 v_data; +layout (std140) uniform CircleEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_stroke_color; + mediump float u_radius; + lowp float u_blur; + lowp float u_opacity; + mediump float u_stroke_width; + lowp float u_stroke_opacity; + bool u_scale_with_map; + bool u_pitch_with_map; + lowp float props_pad1; +}; + #ifndef HAS_UNIFORM_u_color in highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_radius in mediump float radius; -#else -uniform mediump float u_radius; #endif #ifndef HAS_UNIFORM_u_blur in lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_stroke_color in highp vec4 stroke_color; -#else -uniform highp vec4 u_stroke_color; #endif #ifndef HAS_UNIFORM_u_stroke_width in mediump float stroke_width; -#else -uniform mediump float u_stroke_width; #endif #ifndef HAS_UNIFORM_u_stroke_opacity in lowp float stroke_opacity; -#else -uniform lowp float u_stroke_opacity; #endif void main() { diff --git a/include/mbgl/shaders/gl/collision_box.hpp b/include/mbgl/shaders/gl/collision_box.hpp index 526af7baf..00f653e30 100644 --- a/include/mbgl/shaders/gl/collision_box.hpp +++ b/include/mbgl/shaders/gl/collision_box.hpp @@ -6,17 +6,35 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "CollisionBoxProgram"; +struct ShaderSource { + static constexpr const char* name = "CollisionBoxShader"; static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_anchor_pos; layout (location = 2) in vec2 a_extrude; layout (location = 3) in vec2 a_placed; layout (location = 4) in vec2 a_shift; -uniform mat4 u_matrix; -uniform vec2 u_extrude_scale; -uniform float u_camera_to_center_distance; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CollisionDrawableUBO { + highp mat4 u_matrix; +}; + +layout (std140) uniform CollisionTilePropsUBO { + highp vec2 u_extrude_scale; + highp float u_overscale_factor; + lowp float drawable_pad1; +}; out float v_placed; out float v_notUsed; @@ -36,8 +54,7 @@ void main() { v_notUsed = a_placed.y; } )"; - static constexpr const char* fragment = R"( -in float v_placed; + static constexpr const char* fragment = R"(in float v_placed; in float v_notUsed; void main() { @@ -56,7 +73,8 @@ void main() { // This box not used, fade it out fragColor *= .1; } -})"; +} +)"; }; } // namespace shaders diff --git a/include/mbgl/shaders/gl/collision_circle.hpp b/include/mbgl/shaders/gl/collision_circle.hpp index 05a5217d9..437692d80 100644 --- a/include/mbgl/shaders/gl/collision_circle.hpp +++ b/include/mbgl/shaders/gl/collision_circle.hpp @@ -6,16 +6,34 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "CollisionCircleProgram"; +struct ShaderSource { + static constexpr const char* name = "CollisionCircleShader"; static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_anchor_pos; layout (location = 2) in vec2 a_extrude; layout (location = 3) in vec2 a_placed; -uniform mat4 u_matrix; -uniform vec2 u_extrude_scale; -uniform float u_camera_to_center_distance; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CollisionDrawableUBO { + highp mat4 u_matrix; +}; + +layout (std140) uniform CollisionTilePropsUBO { + highp vec2 u_extrude_scale; + highp float u_overscale_factor; + lowp float drawable_pad1; +}; out float v_placed; out float v_notUsed; @@ -44,7 +62,23 @@ void main() { v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio; } )"; - static constexpr const char* fragment = R"(uniform float u_overscale_factor; + static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CollisionTilePropsUBO { + highp vec2 u_extrude_scale; + highp float u_overscale_factor; + lowp float drawable_pad1; +}; in float v_placed; in float v_notUsed; diff --git a/include/mbgl/shaders/gl/drawable_custom_geometry.hpp b/include/mbgl/shaders/gl/custom_geometry.hpp similarity index 98% rename from include/mbgl/shaders/gl/drawable_custom_geometry.hpp rename to include/mbgl/shaders/gl/custom_geometry.hpp index cd4ad6820..6c1c8082f 100644 --- a/include/mbgl/shaders/gl/drawable_custom_geometry.hpp +++ b/include/mbgl/shaders/gl/custom_geometry.hpp @@ -21,7 +21,8 @@ out vec2 frag_uv; void main() { frag_uv = a_uv; gl_Position = u_matrix * vec4(a_pos, 1.0); -})"; +} +)"; static constexpr const char* fragment = R"(layout (std140) uniform CustomGeometryDrawableUBO { mat4 u_matrix; vec4 u_color; @@ -32,7 +33,8 @@ uniform sampler2D u_image; void main() { fragColor = texture(u_image, frag_uv) * u_color; -})"; +} +)"; }; } // namespace shaders diff --git a/include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp b/include/mbgl/shaders/gl/custom_symbol_icon.hpp similarity index 100% rename from include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp rename to include/mbgl/shaders/gl/custom_symbol_icon.hpp diff --git a/include/mbgl/shaders/gl/debug.hpp b/include/mbgl/shaders/gl/debug.hpp index 4c0ef97ad..c0782a655 100644 --- a/include/mbgl/shaders/gl/debug.hpp +++ b/include/mbgl/shaders/gl/debug.hpp @@ -6,13 +6,19 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "DebugProgram"; +struct ShaderSource { + static constexpr const char* name = "DebugShader"; static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; out vec2 v_uv; -uniform mat4 u_matrix; -uniform float u_overlay_scale; +layout (std140) uniform DebugUBO { + highp mat4 u_matrix; + highp vec4 u_color; + highp float u_overlay_scale; + lowp float pad1; + lowp float pad2; + lowp float pad3; +}; void main() { // This vertex shader expects a EXTENT x EXTENT quad, @@ -21,7 +27,15 @@ void main() { gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, 0, 1); } )"; - static constexpr const char* fragment = R"(uniform highp vec4 u_color; + static constexpr const char* fragment = R"(layout (std140) uniform DebugUBO { + highp mat4 u_matrix; + highp vec4 u_color; + highp float u_overlay_scale; + lowp float pad1; + lowp float pad2; + lowp float pad3; +}; + uniform sampler2D u_overlay; in vec2 v_uv; diff --git a/include/mbgl/shaders/gl/drawable_background.hpp b/include/mbgl/shaders/gl/drawable_background.hpp deleted file mode 100644 index 9e7e233a1..000000000 --- a/include/mbgl/shaders/gl/drawable_background.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "BackgroundShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -layout (std140) uniform BackgroundDrawableUBO { - highp mat4 u_matrix; -}; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform BackgroundPropsUBO { - highp vec4 u_color; - highp float u_opacity; - lowp float props_pad1; - lowp float props_pad2; - lowp float props_pad3; -}; - -void main() { - fragColor = u_color * u_opacity; -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_background_pattern.hpp b/include/mbgl/shaders/gl/drawable_background_pattern.hpp deleted file mode 100644 index 94cacec93..000000000 --- a/include/mbgl/shaders/gl/drawable_background_pattern.hpp +++ /dev/null @@ -1,94 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "BackgroundPatternShader"; - static constexpr const char* vertex = R"(layout (std140) uniform BackgroundPatternDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_tile_units_to_pixels; - lowp float drawable_pad1; - lowp float drawable_pad2; - lowp float drawable_pad3; -}; - -layout (std140) uniform BackgroundPatternPropsUBO { - highp vec2 u_pattern_tl_a; - highp vec2 u_pattern_br_a; - highp vec2 u_pattern_tl_b; - highp vec2 u_pattern_br_b; - highp vec2 u_pattern_size_a; - highp vec2 u_pattern_size_b; - highp float u_scale_a; - highp float u_scale_b; - highp float u_mix; - highp float u_opacity; -}; - -layout (location = 0) in vec2 a_pos; -out mediump vec2 v_pos_a; -out mediump vec2 v_pos_b; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform BackgroundPatternPropsUBO { - highp vec2 u_pattern_tl_a; - highp vec2 u_pattern_br_a; - highp vec2 u_pattern_tl_b; - highp vec2 u_pattern_br_b; - highp vec2 u_pattern_size_a; - highp vec2 u_pattern_size_b; - highp float u_scale_a; - highp float u_scale_b; - highp float u_mix; - highp float u_opacity; -}; - -uniform sampler2D u_image; - -in mediump vec2 v_pos_a; -in mediump vec2 v_pos_b; - -void main() { - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(u_pattern_tl_a / u_pattern_atlas_texsize, u_pattern_br_a / u_pattern_atlas_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(u_pattern_tl_b / u_pattern_atlas_texsize, u_pattern_br_b / u_pattern_atlas_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - fragColor = mix(color1, color2, u_mix) * u_opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_circle.hpp b/include/mbgl/shaders/gl/drawable_circle.hpp deleted file mode 100644 index 54b0ab20d..000000000 --- a/include/mbgl/shaders/gl/drawable_circle.hpp +++ /dev/null @@ -1,242 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "CircleShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -out vec3 v_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CircleDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_extrude_scale; - // Interpolations - lowp float u_color_t; - lowp float u_radius_t; - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_stroke_color_t; - lowp float u_stroke_width_t; - lowp float u_stroke_opacity_t; - lowp float drawable_pad1; - lowp float drawable_pad2; - lowp float drawable_pad3; -}; - -layout (std140) uniform CircleEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_stroke_color; - mediump float u_radius; - lowp float u_blur; - lowp float u_opacity; - mediump float u_stroke_width; - lowp float u_stroke_opacity; - bool u_scale_with_map; - bool u_pitch_with_map; - lowp float props_pad1; -}; - -#ifndef HAS_UNIFORM_u_color -layout (location = 1) in highp vec4 a_color; -out highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_radius -layout (location = 2) in mediump vec2 a_radius; -out mediump float radius; -#endif -#ifndef HAS_UNIFORM_u_blur -layout (location = 3) in lowp vec2 a_blur; -out lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 4) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_stroke_color -layout (location = 5) in highp vec4 a_stroke_color; -out highp vec4 stroke_color; -#endif -#ifndef HAS_UNIFORM_u_stroke_width -layout (location = 6) in mediump vec2 a_stroke_width; -out mediump float stroke_width; -#endif -#ifndef HAS_UNIFORM_u_stroke_opacity -layout (location = 7) in lowp vec2 a_stroke_opacity; -out lowp float stroke_opacity; -#endif - -void main(void) { - #ifndef HAS_UNIFORM_u_color -color = unpack_mix_color(a_color, u_color_t); -#else -highp vec4 color = u_color; -#endif - #ifndef HAS_UNIFORM_u_radius -radius = unpack_mix_vec2(a_radius, u_radius_t); -#else -mediump float radius = u_radius; -#endif - #ifndef HAS_UNIFORM_u_blur -blur = unpack_mix_vec2(a_blur, u_blur_t); -#else -lowp float blur = u_blur; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_stroke_color -stroke_color = unpack_mix_color(a_stroke_color, u_stroke_color_t); -#else -highp vec4 stroke_color = u_stroke_color; -#endif - #ifndef HAS_UNIFORM_u_stroke_width -stroke_width = unpack_mix_vec2(a_stroke_width, u_stroke_width_t); -#else -mediump float stroke_width = u_stroke_width; -#endif - #ifndef HAS_UNIFORM_u_stroke_opacity -stroke_opacity = unpack_mix_vec2(a_stroke_opacity, u_stroke_opacity_t); -#else -lowp float stroke_opacity = u_stroke_opacity; -#endif - - // unencode the extrusion vector that we snuck into the a_pos vector - vec2 extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); - - // multiply a_pos by 0.5, since we had it * 2 in order to sneak - // in extrusion data - vec2 circle_center = floor(a_pos * 0.5); - if (u_pitch_with_map) { - vec2 corner_position = circle_center; - if (u_scale_with_map) { - corner_position += extrude * (radius + stroke_width) * u_extrude_scale; - } else { - // Pitching the circle with the map effectively scales it with the map - // To counteract the effect for pitch-scale: viewport, we rescale the - // whole circle based on the pitch scaling effect at its central point - vec4 projected_center = u_matrix * vec4(circle_center, 0, 1); - corner_position += extrude * (radius + stroke_width) * u_extrude_scale * (projected_center.w / u_camera_to_center_distance); - } - - gl_Position = u_matrix * vec4(corner_position, 0, 1); - } else { - gl_Position = u_matrix * vec4(circle_center, 0, 1); - - if (u_scale_with_map) { - gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * u_camera_to_center_distance; - } else { - gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * gl_Position.w; - } - } - - // This is a minimum blur distance that serves as a faux-antialiasing for - // the circle. since blur is a ratio of the circle's size and the intent is - // to keep the blur at roughly 1px, the two are inversely related. - lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width); - - v_data = vec3(extrude.x, extrude.y, antialiasblur); -} -)"; - static constexpr const char* fragment = R"(in vec3 v_data; - -layout (std140) uniform CircleEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_stroke_color; - mediump float u_radius; - lowp float u_blur; - lowp float u_opacity; - mediump float u_stroke_width; - lowp float u_stroke_opacity; - bool u_scale_with_map; - bool u_pitch_with_map; - lowp float props_pad1; -}; - -#ifndef HAS_UNIFORM_u_color -in highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_radius -in mediump float radius; -#endif -#ifndef HAS_UNIFORM_u_blur -in lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_stroke_color -in highp vec4 stroke_color; -#endif -#ifndef HAS_UNIFORM_u_stroke_width -in mediump float stroke_width; -#endif -#ifndef HAS_UNIFORM_u_stroke_opacity -in lowp float stroke_opacity; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_color -highp vec4 color = u_color; -#endif - #ifdef HAS_UNIFORM_u_radius -mediump float radius = u_radius; -#endif - #ifdef HAS_UNIFORM_u_blur -lowp float blur = u_blur; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - #ifdef HAS_UNIFORM_u_stroke_color -highp vec4 stroke_color = u_stroke_color; -#endif - #ifdef HAS_UNIFORM_u_stroke_width -mediump float stroke_width = u_stroke_width; -#endif - #ifdef HAS_UNIFORM_u_stroke_opacity -lowp float stroke_opacity = u_stroke_opacity; -#endif - - vec2 extrude = v_data.xy; - float extrude_length = length(extrude); - - lowp float antialiasblur = v_data.z; - float antialiased_blur = -max(blur, antialiasblur); - - float opacity_t = smoothstep(0.0, antialiased_blur, extrude_length - 1.0); - - float color_t = stroke_width < 0.01 ? 0.0 : smoothstep( - antialiased_blur, - 0.0, - extrude_length - radius / (radius + stroke_width) - ); - - fragColor = opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_collision_box.hpp b/include/mbgl/shaders/gl/drawable_collision_box.hpp deleted file mode 100644 index 6be0126ab..000000000 --- a/include/mbgl/shaders/gl/drawable_collision_box.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "CollisionBoxShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_anchor_pos; -layout (location = 2) in vec2 a_extrude; -layout (location = 3) in vec2 a_placed; -layout (location = 4) in vec2 a_shift; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CollisionDrawableUBO { - highp mat4 u_matrix; -}; - -layout (std140) uniform CollisionTilePropsUBO { - highp vec2 u_extrude_scale; - highp float u_overscale_factor; - lowp float drawable_pad1; -}; - -out float v_placed; -out 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 = 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 + a_shift) * u_extrude_scale * gl_Position.w * collision_perspective_ratio; - - v_placed = a_placed.x; - v_notUsed = a_placed.y; -} -)"; - static constexpr const char* fragment = R"(in float v_placed; -in float v_notUsed; - -void main() { - - float alpha = 0.5; - - // Red = collision, hide label - fragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha; - - // Blue = no collision, label is showing - if (v_placed > 0.5) { - fragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha; - } - - if (v_notUsed > 0.5) { - // This box not used, fade it out - fragColor *= .1; - } -})"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_collision_circle.hpp b/include/mbgl/shaders/gl/drawable_collision_circle.hpp deleted file mode 100644 index 437692d80..000000000 --- a/include/mbgl/shaders/gl/drawable_collision_circle.hpp +++ /dev/null @@ -1,119 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "CollisionCircleShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_anchor_pos; -layout (location = 2) in vec2 a_extrude; -layout (location = 3) in vec2 a_placed; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CollisionDrawableUBO { - highp mat4 u_matrix; -}; - -layout (std140) uniform CollisionTilePropsUBO { - highp vec2 u_extrude_scale; - highp float u_overscale_factor; - lowp float drawable_pad1; -}; - -out float v_placed; -out float v_notUsed; -out float v_radius; -out highp vec2 v_extrude; -out vec2 v_extrude_scale; - -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 = clamp( - 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance), - 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles - 4.0); - - gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0); - - highp float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur - gl_Position.xy += a_extrude * u_extrude_scale * padding_factor * gl_Position.w * collision_perspective_ratio; - - v_placed = a_placed.x; - v_notUsed = a_placed.y; - v_radius = abs(a_extrude.y); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius - - v_extrude = a_extrude * padding_factor; - v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio; -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CollisionTilePropsUBO { - highp vec2 u_extrude_scale; - highp float u_overscale_factor; - lowp float drawable_pad1; -}; - -in float v_placed; -in float v_notUsed; -in float v_radius; -in highp vec2 v_extrude; -in vec2 v_extrude_scale; - -void main() { - float alpha = 0.5; - - // Red = collision, hide label - vec4 color = vec4(1.0, 0.0, 0.0, 1.0) * alpha; - - // Blue = no collision, label is showing - if (v_placed > 0.5) { - color = vec4(0.0, 0.0, 1.0, 0.5) * alpha; - } - - if (v_notUsed > 0.5) { - // This box not used, fade it out - color *= .2; - } - - float extrude_scale_length = length(v_extrude_scale); - float extrude_length = length(v_extrude) * extrude_scale_length; - float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor; - float radius = v_radius * extrude_scale_length; - - float distance_to_edge = abs(extrude_length - radius); - float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge); - - fragColor = opacity_t * color; -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_debug.hpp b/include/mbgl/shaders/gl/drawable_debug.hpp deleted file mode 100644 index c0782a655..000000000 --- a/include/mbgl/shaders/gl/drawable_debug.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "DebugShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -out vec2 v_uv; - -layout (std140) uniform DebugUBO { - highp mat4 u_matrix; - highp vec4 u_color; - highp float u_overlay_scale; - lowp float pad1; - lowp float pad2; - lowp float pad3; -}; - -void main() { - // This vertex shader expects a EXTENT x EXTENT quad, - // The UV co-ordinates for the overlay texture can be calculated using that knowledge - v_uv = a_pos / 8192.0; - gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, 0, 1); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform DebugUBO { - highp mat4 u_matrix; - highp vec4 u_color; - highp float u_overlay_scale; - lowp float pad1; - lowp float pad2; - lowp float pad3; -}; - -uniform sampler2D u_overlay; - -in vec2 v_uv; - -void main() { - vec4 overlay_color = texture(u_overlay, v_uv); - fragColor = mix(u_color, overlay_color, overlay_color.a); -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_fill.hpp b/include/mbgl/shaders/gl/drawable_fill.hpp deleted file mode 100644 index 58e2ab57b..000000000 --- a/include/mbgl/shaders/gl/drawable_fill.hpp +++ /dev/null @@ -1,89 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "FillShader"; - static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO { - highp mat4 u_matrix; - // Interpolations - highp float u_color_t; - highp float u_opacity_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -#ifndef HAS_UNIFORM_u_color -layout (location = 1) in highp vec4 a_color; -out highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 2) in lowp vec2 a_opacity; -out lowp float opacity; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_color -color = unpack_mix_color(a_color, u_color_t); -#else -highp vec4 color = u_color; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -#ifndef HAS_UNIFORM_u_color -in highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_color -highp vec4 color = u_color; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - - fragColor = color * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp b/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp deleted file mode 100644 index 10a7d912f..000000000 --- a/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp +++ /dev/null @@ -1,139 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "FillExtrusionShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec4 a_normal_ed; -out vec4 v_color; - -layout (std140) uniform FillExtrusionDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_height_factor; - highp float u_tile_ratio; - // Interpolations - highp float u_base_t; - highp float u_height_t; - highp float u_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform FillExtrusionTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillExtrusionPropsUBO { - highp vec4 u_color; - highp vec3 u_lightcolor; - lowp float props_pad1; - highp vec3 u_lightpos; - highp float u_base; - highp float u_height; - highp float u_lightintensity; - highp float u_vertical_gradient; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; - lowp float props_pad2; -}; - -#ifndef HAS_UNIFORM_u_base -layout (location = 2) in highp vec2 a_base; -#endif -#ifndef HAS_UNIFORM_u_height -layout (location = 3) in highp vec2 a_height; -#endif -#ifndef HAS_UNIFORM_u_color -layout (location = 4) in highp vec4 a_color; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_base -highp float base = unpack_mix_vec2(a_base, u_base_t); -#else -highp float base = u_base; -#endif - #ifndef HAS_UNIFORM_u_height -highp float height = unpack_mix_vec2(a_height, u_height_t); -#else -highp float height = u_height; -#endif - #ifndef HAS_UNIFORM_u_color -highp vec4 color = unpack_mix_color(a_color, u_color_t); -#else -highp vec4 color = u_color; -#endif - - vec3 normal = a_normal_ed.xyz; - - base = max(0.0, base); - height = max(0.0, height); - - float t = mod(normal.x, 2.0); - - gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1); - - // Relative luminance (how dark/bright is the surface color?) - float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722; - - v_color = vec4(0.0, 0.0, 0.0, 1.0); - - // Add slight ambient lighting so no extrusions are totally black - vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0); - color += ambientlight; - - // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray - float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0); - - // Adjust directional so that - // the range of values for highlight/shading is narrower - // with lower light intensity - // and with lighter/brighter surface colors - directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional); - - // Add gradient along z axis of side surfaces - if (normal.y != 0.0) { - // This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient, - // and otherwise calculates the gradient based on base + height - directional *= ( - (1.0 - u_vertical_gradient) + - (u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0))); - } - - // Assign final color based on surface + ambient light color, diffuse light directional, and light color - // with lower bounds adjusted to hue of light - // so that shading is tinted with the complementary (opposite) color to the light color - v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0); - v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0); - v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0); - v_color *= u_opacity; -} -)"; - static constexpr const char* fragment = R"(in vec4 v_color; - -void main() { - fragColor = v_color; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp deleted file mode 100644 index 11f7e40c4..000000000 --- a/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp +++ /dev/null @@ -1,237 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "FillExtrusionPatternShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec4 a_normal_ed; - -out vec2 v_pos_a; -out vec2 v_pos_b; -out vec4 v_lighting; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillExtrusionDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_height_factor; - highp float u_tile_ratio; - // Interpolations - highp float u_base_t; - highp float u_height_t; - highp float u_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform FillExtrusionTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillExtrusionPropsUBO { - highp vec4 u_color; - highp vec3 u_lightcolor; - lowp float props_pad1; - highp vec3 u_lightpos; - highp float u_base; - highp float u_height; - highp float u_lightintensity; - highp float u_vertical_gradient; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; - lowp float props_pad2; -}; - -#ifndef HAS_UNIFORM_u_base -layout (location = 2) in lowp vec2 a_base; -out lowp float base; -#endif -#ifndef HAS_UNIFORM_u_height -layout (location = 3) in lowp vec2 a_height; -out lowp float height; -#endif -#ifndef HAS_UNIFORM_u_pattern_from -layout (location = 4) in mediump vec4 a_pattern_from; -out mediump vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -layout (location = 5) in mediump vec4 a_pattern_to; -out mediump vec4 pattern_to; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_base -base = unpack_mix_vec2(a_base, u_base_t); -#else -lowp float base = u_base; -#endif - #ifndef HAS_UNIFORM_u_height -height = unpack_mix_vec2(a_height, u_height_t); -#else -lowp float height = u_height; -#endif - #ifndef HAS_UNIFORM_u_pattern_from -pattern_from = a_pattern_from; -#else -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifndef HAS_UNIFORM_u_pattern_to -pattern_to = a_pattern_to; -#else -mediump vec4 pattern_to = u_pattern_to; -#endif - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_pixel_ratio; - float tileRatio = u_tile_ratio; - float fromScale = u_from_scale; - float toScale = u_to_scale; - - vec3 normal = a_normal_ed.xyz; - float edgedistance = a_normal_ed.w; - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - - base = max(0.0, base); - height = max(0.0, height); - - float t = mod(normal.x, 2.0); - float z = t > 0.0 ? height : base; - - gl_Position = u_matrix * vec4(a_pos, z, 1); - - vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0 - ? a_pos // extrusion top - : vec2(edgedistance, z * u_height_factor); // extrusion side - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, pos); - - v_lighting = vec4(0.0, 0.0, 0.0, 1.0); - float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0); - directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional); - - if (normal.y != 0.0) { - // This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient, - // and otherwise calculates the gradient based on base + height - directional *= ( - (1.0 - u_vertical_gradient) + - (u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0))); - } - - v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0)); - v_lighting *= u_opacity; -} -)"; - static constexpr const char* fragment = R"(in vec2 v_pos_a; -in vec2 v_pos_b; -in vec4 v_lighting; - -layout (std140) uniform FillExtrusionTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillExtrusionPropsUBO { - highp vec4 u_color; - highp vec3 u_lightcolor; - lowp float props_pad1; - highp vec3 u_lightpos; - highp float u_base; - highp float u_height; - highp float u_lightintensity; - highp float u_vertical_gradient; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -#ifndef HAS_UNIFORM_u_base -in lowp float base; -#endif -#ifndef HAS_UNIFORM_u_height -in lowp float height; -#endif -#ifndef HAS_UNIFORM_u_pattern_from -in mediump vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -in mediump vec4 pattern_to; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_base -lowp float base = u_base; -#endif - #ifdef HAS_UNIFORM_u_height -lowp float height = u_height; -#endif - #ifdef HAS_UNIFORM_u_pattern_from -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifdef HAS_UNIFORM_u_pattern_to -mediump vec4 pattern_to = u_pattern_to; -#endif - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - vec4 mixedColor = mix(color1, color2, u_fade); - - fragColor = mixedColor * v_lighting; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_fill_outline.hpp b/include/mbgl/shaders/gl/drawable_fill_outline.hpp deleted file mode 100644 index ae157ae5f..000000000 --- a/include/mbgl/shaders/gl/drawable_fill_outline.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "FillOutlineShader"; - static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillOutlineDrawableUBO { - highp mat4 u_matrix; - // Interpolations - highp float u_outline_color_t; - highp float u_opacity_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -out vec2 v_pos; - -#ifndef HAS_UNIFORM_u_outline_color -layout (location = 1) in highp vec4 a_outline_color; -out highp vec4 outline_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 2) in lowp vec2 a_opacity; -out lowp float opacity; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_outline_color -outline_color = unpack_mix_color(a_outline_color, u_outline_color_t); -#else -highp vec4 outline_color = u_outline_color; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - - gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -in vec2 v_pos; - -#ifndef HAS_UNIFORM_u_outline_color -in highp vec4 outline_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_outline_color -highp vec4 outline_color = u_outline_color; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - - float dist = length(v_pos - gl_FragCoord.xy); - float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - fragColor = outline_color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp deleted file mode 100644 index f197a5631..000000000 --- a/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp +++ /dev/null @@ -1,181 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "FillOutlinePatternShader"; - static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillOutlinePatternDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_tile_ratio; - // Interpolations - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_opacity_t; -}; - -layout (std140) uniform FillOutlinePatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -out vec2 v_pos_a; -out vec2 v_pos_b; -out vec2 v_pos; - -#ifndef HAS_UNIFORM_u_opacity -layout (location = 1) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_pattern_from -layout (location = 2) in lowp vec4 a_pattern_from; -out lowp vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -layout (location = 3) in lowp vec4 a_pattern_to; -out lowp vec4 pattern_to; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_pattern_from -pattern_from = a_pattern_from; -#else -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifndef HAS_UNIFORM_u_pattern_to -pattern_to = a_pattern_to; -#else -mediump vec4 pattern_to = u_pattern_to; -#endif - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_pixel_ratio; - float tileRatio = u_tile_ratio; - float fromScale = u_from_scale; - float toScale = u_to_scale; - - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, a_pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, a_pos); - - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform FillOutlinePatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -uniform sampler2D u_image; - -in vec2 v_pos_a; -in vec2 v_pos_b; -in vec2 v_pos; - -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_pattern_from -in lowp vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -in lowp vec4 pattern_to; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - #ifdef HAS_UNIFORM_u_pattern_from -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifdef HAS_UNIFORM_u_pattern_to -mediump vec4 pattern_to = u_pattern_to; -#endif - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - // find distance to outline for alpha interpolation - - float dist = length(v_pos - gl_FragCoord.xy); - float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - - - fragColor = mix(color1, color2, u_fade) * alpha * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_fill_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_pattern.hpp deleted file mode 100644 index fecf17eda..000000000 --- a/include/mbgl/shaders/gl/drawable_fill_pattern.hpp +++ /dev/null @@ -1,174 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "FillPatternShader"; - static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillPatternDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_tile_ratio; - // Interpolations - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_opacity_t; -}; - -layout (std140) uniform FillPatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -out vec2 v_pos_a; -out vec2 v_pos_b; - -#ifndef HAS_UNIFORM_u_opacity -layout (location = 1) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_pattern_from -layout (location = 2) in lowp vec4 a_pattern_from; -out lowp vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -layout (location = 3) in lowp vec4 a_pattern_to; -out lowp vec4 pattern_to; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_pattern_from -pattern_from = a_pattern_from; -#else -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifndef HAS_UNIFORM_u_pattern_to -pattern_to = a_pattern_to; -#else -mediump vec4 pattern_to = u_pattern_to; -#endif - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_pixel_ratio; - float tileZoomRatio = u_tile_ratio; - float fromScale = u_from_scale; - float toScale = u_to_scale; - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, a_pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform FillPatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -uniform sampler2D u_image; - -in vec2 v_pos_a; -in vec2 v_pos_b; - -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_pattern_from -in lowp vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -in lowp vec4 pattern_to; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - #ifdef HAS_UNIFORM_u_pattern_from -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifdef HAS_UNIFORM_u_pattern_to -mediump vec4 pattern_to = u_pattern_to; -#endif - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - if (u_texsize.x < 1.0 || u_texsize.y < 1.0) { - discard; - } - - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - fragColor = mix(color1, color2, u_fade) * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_heatmap.hpp b/include/mbgl/shaders/gl/drawable_heatmap.hpp deleted file mode 100644 index 9b93c798e..000000000 --- a/include/mbgl/shaders/gl/drawable_heatmap.hpp +++ /dev/null @@ -1,123 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "HeatmapShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -out vec2 v_extrude; - -layout (std140) uniform HeatmapDrawableUBO { - highp mat4 u_matrix; - highp float u_extrude_scale; - // Interpolations - lowp float u_weight_t; - lowp float u_radius_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform HeatmapEvaluatedPropsUBO { - highp float u_weight; - highp float u_radius; - highp float u_intensity; - lowp float props_pad1; -}; - -#ifndef HAS_UNIFORM_u_weight -layout (location = 1) in highp vec2 a_weight; -out highp float weight; -#endif -#ifndef HAS_UNIFORM_u_radius -layout (location = 2) in mediump vec2 a_radius; -#endif - -// Effective "0" in the kernel density texture to adjust the kernel size to; -// this empirically chosen number minimizes artifacts on overlapping kernels -// for typical heatmap cases (assuming clustered source) -const highp float ZERO = 1.0 / 255.0 / 16.0; - -// Gaussian kernel coefficient: 1 / sqrt(2 * PI) -#define GAUSS_COEF 0.3989422804014327 - -void main(void) { - #ifndef HAS_UNIFORM_u_weight -weight = unpack_mix_vec2(a_weight, u_weight_t); -#else -highp float weight = u_weight; -#endif - #ifndef HAS_UNIFORM_u_radius -mediump float radius = unpack_mix_vec2(a_radius, u_radius_t); -#else -mediump float radius = u_radius; -#endif - - // unencode the extrusion vector that we snuck into the a_pos vector - vec2 unscaled_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); - - // This 'extrude' comes in ranging from [-1, -1], to [1, 1]. We'll use - // it to produce the vertices of a square mesh framing the point feature - // we're adding to the kernel density texture. We'll also pass it as - // a varying, so that the fragment shader can determine the distance of - // each fragment from the point feature. - // Before we do so, we need to scale it up sufficiently so that the - // kernel falls effectively to zero at the edge of the mesh. - // That is, we want to know S such that - // weight * u_intensity * GAUSS_COEF * exp(-0.5 * 3.0^2 * S^2) == ZERO - // Which solves to: - // S = sqrt(-2.0 * log(ZERO / (weight * u_intensity * GAUSS_COEF))) / 3.0 - float S = sqrt(-2.0 * log(ZERO / weight / u_intensity / GAUSS_COEF)) / 3.0; - - // Pass the varying in units of radius - v_extrude = S * unscaled_extrude; - - // Scale by radius and the zoom-based scale factor to produce actual - // mesh position - vec2 extrude = v_extrude * radius * u_extrude_scale; - - // multiply a_pos by 0.5, since we had it * 2 in order to sneak - // in extrusion data - vec4 pos = vec4(floor(a_pos * 0.5) + extrude, 0, 1); - - gl_Position = u_matrix * pos; -} -)"; - static constexpr const char* fragment = R"(in vec2 v_extrude; - -layout (std140) uniform HeatmapEvaluatedPropsUBO { - highp float u_weight; - highp float u_radius; - highp float u_intensity; - lowp float props_pad1; -}; - -#ifndef HAS_UNIFORM_u_weight -in highp float weight; -#endif - -// Gaussian kernel coefficient: 1 / sqrt(2 * PI) -#define GAUSS_COEF 0.3989422804014327 - -void main() { - #ifdef HAS_UNIFORM_u_weight -highp float weight = u_weight; -#endif - - // Kernel density estimation with a Gaussian kernel of size 5x5 - float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude); - float val = weight * u_intensity * GAUSS_COEF * exp(d); - - fragColor = vec4(val, 1.0, 1.0, 1.0); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp b/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp deleted file mode 100644 index 19317a2d6..000000000 --- a/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "HeatmapTextureShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -out vec2 v_pos; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform HeatmapTexturePropsUBO { - highp mat4 u_matrix; - highp float u_opacity; - lowp float props_pad1; - lowp float props_pad2; - lowp float props_pad3; -}; - -void main() { - gl_Position = u_matrix * vec4(a_pos * u_world_size, 0, 1); - - v_pos.x = a_pos.x; - v_pos.y = 1.0 - a_pos.y; -} -)"; - static constexpr const char* fragment = R"(in vec2 v_pos; -uniform sampler2D u_image; -uniform sampler2D u_color_ramp; - -layout (std140) uniform HeatmapTexturePropsUBO { - highp mat4 u_matrix; - highp float u_opacity; - lowp float props_pad1; - lowp float props_pad2; - lowp float props_pad3; -}; - -void main() { - float t = texture(u_image, v_pos).r; - vec4 color = texture(u_color_ramp, vec2(t, 0.5)); - fragColor = color * u_opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(0.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_hillshade.hpp b/include/mbgl/shaders/gl/drawable_hillshade.hpp deleted file mode 100644 index 8d1865380..000000000 --- a/include/mbgl/shaders/gl/drawable_hillshade.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "HillshadeShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_texture_pos; - -layout (std140) uniform HillshadeDrawableUBO { - highp mat4 u_matrix; -}; - -out vec2 v_pos; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos = a_texture_pos / 8192.0; -} -)"; - static constexpr const char* fragment = R"(in vec2 v_pos; -uniform sampler2D u_image; - -layout (std140) uniform HillshadeTilePropsUBO { - highp vec2 u_latrange; - highp vec2 u_light; -}; - -layout (std140) uniform HillshadeEvaluatedPropsUBO { - highp vec4 u_highlight; - highp vec4 u_shadow; - highp vec4 u_accent; -}; - -#define PI 3.141592653589793 - -void main() { - vec4 pixel = texture(u_image, v_pos); - - vec2 deriv = ((pixel.rg * 2.0) - 1.0); - - // We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude - // to account for mercator projection distortion. see #4807 for details - float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1])); - // We also multiply the slope by an arbitrary z-factor of 1.25 - float slope = atan(1.25 * length(deriv) / scaleFactor); - float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0); - - float intensity = u_light.x; - // We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal - // position property to account for 0deg corresponding to north/the top of the viewport in the style spec - // and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal. - float azimuth = u_light.y + PI; - - // We scale the slope exponentially based on intensity, using a calculation similar to - // the exponential interpolation function in the style spec: - // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/expression/definitions/interpolate.js#L217-L228 - // so that higher intensity values create more opaque hillshading. - float base = 1.875 - intensity * 1.75; - float maxValue = 0.5 * PI; - float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope; - - // The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine - // so that the accent color's rate of change eases in while the shade color's eases out. - float accent = cos(scaledSlope); - // We multiply both the accent and shade color by a clamped intensity value - // so that intensities >= 0.5 do not additionally affect the color values - // while intensity values < 0.5 make the overall color more transparent. - vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0); - float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0); - vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0); - fragColor = accent_color * (1.0 - shade_color.a) + shade_color; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp b/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp deleted file mode 100644 index 2a2bf01b5..000000000 --- a/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp +++ /dev/null @@ -1,116 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "HillshadePrepareShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_texture_pos; - -layout (std140) uniform HillshadePrepareDrawableUBO { - highp mat4 u_matrix; -}; - -layout (std140) uniform HillshadePrepareTilePropsUBO { - highp vec4 u_unpack; - highp vec2 u_dimension; - highp float u_zoom; - highp float u_maxzoom; -}; - -out vec2 v_pos; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - highp vec2 epsilon = 1.0 / u_dimension; - float scale = (u_dimension.x - 2.0) / u_dimension.x; - v_pos = (a_texture_pos / 8192.0) * scale + epsilon; -} -)"; - static constexpr const char* fragment = R"(#ifdef GL_ES -precision highp float; -#endif - -in vec2 v_pos; -uniform sampler2D u_image; - -layout (std140) uniform HillshadePrepareTilePropsUBO { - highp vec4 u_unpack; - highp vec2 u_dimension; - highp float u_zoom; - highp float u_maxzoom; -}; - -float getElevation(vec2 coord, float bias) { - // Convert encoded elevation value to meters - vec4 data = texture(u_image, coord) * 255.0; - data.a = -1.0; - return dot(data, u_unpack) / 4.0; -} - -void main() { - vec2 epsilon = 1.0 / u_dimension; - - // queried pixels: - // +-----------+ - // | | | | - // | a | b | c | - // | | | | - // +-----------+ - // | | | | - // | d | e | f | - // | | | | - // +-----------+ - // | | | | - // | g | h | i | - // | | | | - // +-----------+ - - float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0); - float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0); - float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0); - float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0); - //float e = getElevation(v_pos, 0.0); - float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0); - float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0); - float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0); - float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0); - - // here we divide the x and y slopes by 8 * pixel size - // where pixel size (aka meters/pixel) is: - // circumference of the world / (pixels per tile * number of tiles) - // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom)) - // which can be reduced to: pow(2, 19.25619978527 - u_zoom) - // we want to vertically exaggerate the hillshading though, because otherwise - // it is barely noticeable at low zooms. to do this, we multiply this by some - // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value - // Here we use a=0.3 which works out to the expression below. see - // nickidlugash's awesome breakdown for more info - // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556 - float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3; - - vec2 deriv = vec2( - (c + f + f + i) - (a + d + d + g), - (g + h + h + i) - (a + b + b + c) - ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom); - - fragColor = clamp(vec4( - deriv.x / 2.0 + 0.5, - deriv.y / 2.0 + 0.5, - 1.0, - 1.0), 0.0, 1.0); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_line.hpp b/include/mbgl/shaders/gl/drawable_line.hpp deleted file mode 100644 index 1f0935817..000000000 --- a/include/mbgl/shaders/gl/drawable_line.hpp +++ /dev/null @@ -1,224 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "LineShader"; - static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform LineDrawableUBO { - highp mat4 u_matrix; - mediump float u_ratio; - // Interpolations - lowp float u_color_t; - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_gapwidth_t; - lowp float u_offset_t; - lowp float u_width_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out float v_gamma_scale; -out highp float v_linesofar; - -#ifndef HAS_UNIFORM_u_color -layout (location = 2) in highp vec4 a_color; -out highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_blur -layout (location = 3) in lowp vec2 a_blur; -out lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 4) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_gapwidth -layout (location = 5) in mediump vec2 a_gapwidth; -#endif -#ifndef HAS_UNIFORM_u_offset -layout (location = 6) in lowp vec2 a_offset; -#endif -#ifndef HAS_UNIFORM_u_width -layout (location = 7) in mediump vec2 a_width; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_color -color = unpack_mix_color(a_color, u_color_t); -#else -highp vec4 color = u_color; -#endif - #ifndef HAS_UNIFORM_u_blur -blur = unpack_mix_vec2(a_blur, u_blur_t); -#else -lowp float blur = u_blur; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_gapwidth -mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); -#else -mediump float gapwidth = u_gapwidth; -#endif - #ifndef HAS_UNIFORM_u_offset -lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); -#else -lowp float offset = u_offset; -#endif - #ifndef HAS_UNIFORM_u_width -mediump float width = unpack_mix_vec2(a_width, u_width_t); -#else -mediump float width = u_width; -#endif - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - - v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0; - - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist = outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_width2 = vec2(outset, inset); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -in vec2 v_width2; -in vec2 v_normal; -in float v_gamma_scale; - -#ifndef HAS_UNIFORM_u_color -in highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_blur -in lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_color -highp vec4 color = u_color; -#endif - #ifdef HAS_UNIFORM_u_blur -lowp float blur = u_blur; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - fragColor = color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_line_gradient.hpp b/include/mbgl/shaders/gl/drawable_line_gradient.hpp deleted file mode 100644 index c77e020c4..000000000 --- a/include/mbgl/shaders/gl/drawable_line_gradient.hpp +++ /dev/null @@ -1,220 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "LineGradientShader"; - static constexpr const char* vertex = R"( -// the attribute conveying progress along a line is scaled to [0, 2^15) -#define MAX_LINE_DISTANCE 32767.0 - -// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform LineGradientDrawableUBO { - highp mat4 u_matrix; - mediump float u_ratio; - // Interpolations - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_gapwidth_t; - lowp float u_offset_t; - lowp float u_width_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out float v_gamma_scale; -out highp float v_lineprogress; - -#ifndef HAS_UNIFORM_u_blur -layout (location = 2) in lowp vec2 a_blur; -out lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 3) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_gapwidth -layout (location = 4) in mediump vec2 a_gapwidth; -#endif -#ifndef HAS_UNIFORM_u_offset -layout (location = 5) in lowp vec2 a_offset; -#endif -#ifndef HAS_UNIFORM_u_width -layout (location = 6) in mediump vec2 a_width; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_blur -blur = unpack_mix_vec2(a_blur, u_blur_t); -#else -lowp float blur = u_blur; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_gapwidth -mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); -#else -mediump float gapwidth = u_gapwidth; -#endif - #ifndef HAS_UNIFORM_u_offset -lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); -#else -lowp float offset = u_offset; -#endif - #ifndef HAS_UNIFORM_u_width -mediump float width = unpack_mix_vec2(a_width, u_width_t); -#else -mediump float width = u_width; -#endif - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - - v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE; - - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist = outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_width2 = vec2(outset, inset); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -in vec2 v_width2; -in vec2 v_normal; -in float v_gamma_scale; -in highp float v_lineprogress; - -#ifndef HAS_UNIFORM_u_blur -in lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_blur -lowp float blur = u_blur; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - // For gradient lines, v_lineprogress is the ratio along the entire line, - // scaled to [0, 2^15), and the gradient ramp is stored in a texture. - vec4 color = texture(u_image, vec2(v_lineprogress, 0.5)); - - fragColor = color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_line_pattern.hpp b/include/mbgl/shaders/gl/drawable_line_pattern.hpp deleted file mode 100644 index ea4b8809f..000000000 --- a/include/mbgl/shaders/gl/drawable_line_pattern.hpp +++ /dev/null @@ -1,295 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "LinePatternShader"; - static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -// We scale the distance before adding it to the buffers so that we can store -// long distances for long segments. Use this value to unscale the distance. -#define LINE_DISTANCE_SCALE 2.0 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; -layout (std140) uniform LinePatternDrawableUBO { - highp mat4 u_matrix; - mediump float u_ratio; - // Interpolations - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_offset_t; - lowp float u_gapwidth_t; - lowp float u_width_t; - lowp float u_pattern_from_t; - lowp float u_pattern_to_t; -}; - -layout (std140) uniform LinePatternTilePropsUBO { - lowp vec4 u_pattern_from; - lowp vec4 u_pattern_to; - mediump vec4 u_scale; - highp vec2 u_texsize; - highp float u_fade; - lowp float tileprops_pad1; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out float v_linesofar; -out float v_gamma_scale; - -#ifndef HAS_UNIFORM_u_blur -layout (location = 2) in lowp vec2 a_blur; -out lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 3) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_offset -layout (location = 4) in lowp vec2 a_offset; -#endif -#ifndef HAS_UNIFORM_u_gapwidth -layout (location = 5) in mediump vec2 a_gapwidth; -#endif -#ifndef HAS_UNIFORM_u_width -layout (location = 6) in mediump vec2 a_width; -#endif -#ifndef HAS_UNIFORM_u_pattern_from -layout (location = 7) in lowp vec4 a_pattern_from; -out lowp vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -layout (location = 8) in lowp vec4 a_pattern_to; -out lowp vec4 pattern_to; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_blur -blur = unpack_mix_vec2(a_blur, u_blur_t); -#else -lowp float blur = u_blur; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_offset -lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); -#else -lowp float offset = u_offset; -#endif - #ifndef HAS_UNIFORM_u_gapwidth -mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); -#else -mediump float gapwidth = u_gapwidth; -#endif - #ifndef HAS_UNIFORM_u_width -mediump float width = unpack_mix_vec2(a_width, u_width_t); -#else -mediump float width = u_width; -#endif - #ifndef HAS_UNIFORM_u_pattern_from -pattern_from = a_pattern_from; -#else -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifndef HAS_UNIFORM_u_pattern_to -pattern_to = a_pattern_to; -#else -mediump vec4 pattern_to = u_pattern_to; -#endif - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE; - // float tileRatio = u_scale.y; - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist = outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_linesofar = a_linesofar; - v_width2 = vec2(outset, inset); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform LinePatternTilePropsUBO { - lowp vec4 u_pattern_from; - lowp vec4 u_pattern_to; - mediump vec4 u_scale; - highp vec2 u_texsize; - highp float u_fade; - lowp float tileprops_pad1; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -in vec2 v_normal; -in vec2 v_width2; -in float v_linesofar; -in float v_gamma_scale; - -#ifndef HAS_UNIFORM_u_pattern_from -in lowp vec4 pattern_from; -#endif -#ifndef HAS_UNIFORM_u_pattern_to -in lowp vec4 pattern_to; -#endif -#ifndef HAS_UNIFORM_u_blur -in lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_pattern_from -mediump vec4 pattern_from = u_pattern_from; -#endif - #ifdef HAS_UNIFORM_u_pattern_to -mediump vec4 pattern_to = u_pattern_to; -#endif - - #ifdef HAS_UNIFORM_u_blur -lowp float blur = u_blur; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_scale.x; - float tileZoomRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - - vec2 pattern_size_a = vec2(display_size_a.x * fromScale / tileZoomRatio, display_size_a.y); - vec2 pattern_size_b = vec2(display_size_b.x * toScale / tileZoomRatio, display_size_b.y); - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - float x_a = mod(v_linesofar / pattern_size_a.x, 1.0); - float x_b = mod(v_linesofar / pattern_size_b.x, 1.0); - - // v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge - // we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0) - // to ensure we don't sample outside the designated symbol on the sprite sheet. - // 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of - // the texture coordinate - 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); - 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); - vec2 pos_a = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, vec2(x_a, y_a)); - vec2 pos_b = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, vec2(x_b, y_b)); - - vec4 color = mix(texture(u_image, pos_a), texture(u_image, pos_b), u_fade); - - fragColor = color * alpha * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_line_sdf.hpp b/include/mbgl/shaders/gl/drawable_line_sdf.hpp deleted file mode 100644 index 7772658f2..000000000 --- a/include/mbgl/shaders/gl/drawable_line_sdf.hpp +++ /dev/null @@ -1,275 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "LineSDFShader"; - static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -// We scale the distance before adding it to the buffers so that we can store -// long distances for long segments. Use this value to unscale the distance. -#define LINE_DISTANCE_SCALE 2.0 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform LineSDFDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_patternscale_a; - highp vec2 u_patternscale_b; - highp float u_tex_y_a; - highp float u_tex_y_b; - mediump float u_ratio; - // Interpolations - lowp float u_color_t; - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_gapwidth_t; - lowp float u_offset_t; - lowp float u_width_t; - lowp float u_floorwidth_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out vec2 v_tex_a; -out vec2 v_tex_b; -out float v_gamma_scale; - -#ifndef HAS_UNIFORM_u_color -layout (location = 2) in highp vec4 a_color; -out highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_blur -layout (location = 3) in lowp vec2 a_blur; -out lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 4) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_gapwidth -layout (location = 5) in mediump vec2 a_gapwidth; -#endif -#ifndef HAS_UNIFORM_u_offset -layout (location = 6) in lowp vec2 a_offset; -#endif -#ifndef HAS_UNIFORM_u_width -layout (location = 7) in mediump vec2 a_width; -out mediump float width; -#endif -#ifndef HAS_UNIFORM_u_floorwidth -layout (location = 8) in lowp vec2 a_floorwidth; -out lowp float floorwidth; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_color -color = unpack_mix_color(a_color, u_color_t); -#else -highp vec4 color = u_color; -#endif - #ifndef HAS_UNIFORM_u_blur -blur = unpack_mix_vec2(a_blur, u_blur_t); -#else -lowp float blur = u_blur; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_gapwidth -mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); -#else -mediump float gapwidth = u_gapwidth; -#endif - #ifndef HAS_UNIFORM_u_offset -lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); -#else -lowp float offset = u_offset; -#endif - #ifndef HAS_UNIFORM_u_width -width = unpack_mix_vec2(a_width, u_width_t); -#else -mediump float width = u_width; -#endif - #ifndef HAS_UNIFORM_u_floorwidth -floorwidth = unpack_mix_vec2(a_floorwidth, u_floorwidth_t); -#else -lowp float floorwidth = u_floorwidth; -#endif - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE; - - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist =outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a); - v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b); - - v_width2 = vec2(outset, inset); -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform LineSDFTilePropsUBO { - highp float u_sdfgamma; - highp float u_mix; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -in vec2 v_normal; -in vec2 v_width2; -in vec2 v_tex_a; -in vec2 v_tex_b; -in float v_gamma_scale; - -#ifndef HAS_UNIFORM_u_color -in highp vec4 color; -#endif -#ifndef HAS_UNIFORM_u_blur -in lowp float blur; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_width -in mediump float width; -#endif -#ifndef HAS_UNIFORM_u_floorwidth -in lowp float floorwidth; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_color -highp vec4 color = u_color; -#endif - #ifdef HAS_UNIFORM_u_blur -lowp float blur = u_blur; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - #ifdef HAS_UNIFORM_u_width -mediump float width = u_width; -#endif - #ifdef HAS_UNIFORM_u_floorwidth -lowp float floorwidth = u_floorwidth; -#endif - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - float sdfdist_a = texture(u_image, v_tex_a).a; - float sdfdist_b = texture(u_image, v_tex_b).a; - float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix); - alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist); - - fragColor = color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_raster.hpp b/include/mbgl/shaders/gl/drawable_raster.hpp deleted file mode 100644 index ee2865764..000000000 --- a/include/mbgl/shaders/gl/drawable_raster.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "RasterShader"; - static constexpr const char* vertex = R"(layout (std140) uniform RasterDrawableUBO { - highp mat4 u_matrix; -}; -layout (std140) uniform RasterEvaluatedPropsUBO { - highp vec3 u_spin_weights; - highp vec2 u_tl_parent; - highp float u_scale_parent; - highp float u_buffer_scale; - highp float u_fade_t; - highp float u_opacity; - highp float u_brightness_low; - highp float u_brightness_high; - highp float u_saturation_factor; - highp float u_contrast_factor; - lowp float props_pad1; - lowp float props_pad2; -}; - -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_texture_pos; - -out vec2 v_pos0; -out vec2 v_pos1; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - // We are using Int16 for texture position coordinates to give us enough precision for - // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer - // as an arbitrarily high number to preserve adequate precision when rendering. - // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates, - // so math for modifying either is consistent. - v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5; - v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent; -} -)"; - static constexpr const char* fragment = R"(layout (std140) uniform RasterEvaluatedPropsUBO { - highp vec3 u_spin_weights; - highp vec2 u_tl_parent; - highp float u_scale_parent; - highp float u_buffer_scale; - highp float u_fade_t; - highp float u_opacity; - highp float u_brightness_low; - highp float u_brightness_high; - highp float u_saturation_factor; - highp float u_contrast_factor; - lowp float props_pad1; - lowp float props_pad2; -}; -uniform sampler2D u_image0; -uniform sampler2D u_image1; - -in vec2 v_pos0; -in vec2 v_pos1; - -void main() { - - // read and cross-fade colors from the main and parent tiles - vec4 color0 = texture(u_image0, v_pos0); - vec4 color1 = texture(u_image1, v_pos1); - if (color0.a > 0.0) { - color0.rgb = color0.rgb / color0.a; - } - if (color1.a > 0.0) { - color1.rgb = color1.rgb / color1.a; - } - vec4 color = mix(color0, color1, u_fade_t); - color.a *= u_opacity; - vec3 rgb = color.rgb; - - // spin - rgb = vec3( - dot(rgb, u_spin_weights.xyz), - dot(rgb, u_spin_weights.zxy), - dot(rgb, u_spin_weights.yzx)); - - // saturation - float average = (color.r + color.g + color.b) / 3.0; - rgb += (average - rgb) * u_saturation_factor; - - // contrast - rgb = (rgb - 0.5) * u_contrast_factor + 0.5; - - // brightness - vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low); - vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high); - - fragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_icon.hpp deleted file mode 100644 index 9ac73b34a..000000000 --- a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp +++ /dev/null @@ -1,195 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "SymbolIconShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset; -layout (location = 1) in vec4 a_data; -layout (location = 2) in vec4 a_pixeloffset; -layout (location = 3) in vec3 a_projected_pos; -layout (location = 4) in float a_fade_opacity; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform SymbolDrawableUBO { - highp mat4 u_matrix; - highp mat4 u_label_plane_matrix; - highp mat4 u_coord_matrix; - - highp vec2 u_texsize; - highp vec2 u_texsize_icon; - - bool u_is_text_prop; - bool u_rotate_symbol; - bool u_pitch_with_map; - bool u_is_size_zoom_constant; - bool u_is_size_feature_constant; - - highp float u_size_t; // used to interpolate between zoom stops when size is a composite function - highp float u_size; // used when size is both zoom and feature constant - - // Interpolations - highp float u_fill_color_t; - highp float u_halo_color_t; - highp float u_opacity_t; - highp float u_halo_width_t; - highp float u_halo_blur_t; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -out vec2 v_tex; -out float v_fade_opacity; - -#ifndef HAS_UNIFORM_u_opacity -layout (location = 5) in lowp vec2 a_opacity; -out lowp float opacity; -#endif - -void main() { - highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; - - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - - vec2 a_pos = a_pos_offset.xy; - vec2 a_offset = a_pos_offset.zw; - - vec2 a_tex = a_data.xy; - vec2 a_size = a_data.zw; - - float a_size_min = floor(a_size[0] * 0.5); - vec2 a_pxoffset = a_pixeloffset.xy; - vec2 a_minFontScale = a_pixeloffset.zw / 256.0; - - highp float segment_angle = -a_projected_pos[2]; - float size; - - if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = mix(a_size_min, a_size[1], u_size_t) / 128.0; - } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = a_size_min / 128.0; - } else { - size = u_size; - } - - vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1); - highp float camera_to_anchor_distance = projectedPoint.w; - // See comments in symbol_sdf.vertex - 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 = clamp( - 0.5 + 0.5 * distance_ratio, - 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles - 4.0); - - size *= perspective_ratio; - - float fontScale = u_is_text_prop ? size / 24.0 : size; - - highp float symbol_rotation = 0.0; - if (u_rotate_symbol) { - // See comments in symbol_sdf.vertex - vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); - - vec2 a = projectedPoint.xy / projectedPoint.w; - vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; - - symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); - } - - highp float angle_sin = sin(segment_angle + symbol_rotation); - highp float angle_cos = cos(segment_angle + symbol_rotation); - mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); - - vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); - gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * max(a_minFontScale, fontScale) + a_pxoffset / 16.0), 0.0, 1.0); - - v_tex = a_tex / u_texsize; - vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; - v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); -} -)"; - static constexpr const char* fragment = R"(uniform sampler2D u_texture; - -layout (std140) uniform SymbolTilePropsUBO { - bool u_is_text; - bool u_is_halo; - highp float u_gamma_scale; - lowp float tileprops_pad1; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -in vec2 v_tex; -in float v_fade_opacity; - -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif - -void main() { - highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; - - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - - lowp float alpha = opacity * v_fade_opacity; - fragColor = texture(u_texture, v_tex) * alpha; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp deleted file mode 100644 index 4b55116f1..000000000 --- a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp +++ /dev/null @@ -1,320 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "SymbolTextAndIconShader"; - static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset; -layout (location = 1) in vec4 a_data; -layout (location = 2) in vec3 a_projected_pos; -layout (location = 3) in float a_fade_opacity; - -// contents of a_size vary based on the type of property value -// used for {text,icon}-size. -// For constants, a_size is disabled. -// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature. -// For composite functions: -// [ text-size(lowerZoomStop, feature), -// text-size(upperZoomStop, feature) ] - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform SymbolDrawableUBO { - highp mat4 u_matrix; - highp mat4 u_label_plane_matrix; - highp mat4 u_coord_matrix; - - highp vec2 u_texsize; - highp vec2 u_texsize_icon; - - bool u_is_text_prop; - bool u_rotate_symbol; - bool u_pitch_with_map; - bool u_is_size_zoom_constant; - bool u_is_size_feature_constant; - - highp float u_size_t; // used to interpolate between zoom stops when size is a composite function - highp float u_size; // used when size is both zoom and feature constant - - // Interpolations - highp float u_fill_color_t; - highp float u_halo_color_t; - highp float u_opacity_t; - highp float u_halo_width_t; - highp float u_halo_blur_t; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -out vec4 v_data0; -out vec4 v_data1; - -#ifndef HAS_UNIFORM_u_fill_color -layout (location = 4) in highp vec4 a_fill_color; -out highp vec4 fill_color; -#endif -#ifndef HAS_UNIFORM_u_halo_color -layout (location = 5) in highp vec4 a_halo_color; -out highp vec4 halo_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -layout (location = 6) in lowp vec2 a_opacity; -out lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_halo_width -layout (location = 7) in lowp vec2 a_halo_width; -out lowp float halo_width; -#endif -#ifndef HAS_UNIFORM_u_halo_blur -layout (location = 8) in lowp vec2 a_halo_blur; -out lowp float halo_blur; -#endif - -void main() { - highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color; - highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color; - highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; - highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width; - highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur; - - #ifndef HAS_UNIFORM_u_fill_color -fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); -#else -highp vec4 fill_color = u_fill_color; -#endif - #ifndef HAS_UNIFORM_u_halo_color -halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); -#else -highp vec4 halo_color = u_halo_color; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_halo_width -halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); -#else -lowp float halo_width = u_halo_width; -#endif - #ifndef HAS_UNIFORM_u_halo_blur -halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); -#else -lowp float halo_blur = u_halo_blur; -#endif - - vec2 a_pos = a_pos_offset.xy; - vec2 a_offset = a_pos_offset.zw; - - vec2 a_tex = a_data.xy; - vec2 a_size = a_data.zw; - - float a_size_min = floor(a_size[0] * 0.5); - float is_sdf = a_size[0] - 2.0 * a_size_min; - - highp float segment_angle = -a_projected_pos[2]; - float size; - - if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = mix(a_size_min, a_size[1], u_size_t) / 128.0; - } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = a_size_min / 128.0; - } else { - size = u_size; - } - - vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1); - highp float camera_to_anchor_distance = projectedPoint.w; - // If the label is pitched with the map, layout is done in pitched space, - // which makes labels in the distance smaller relative to viewport space. - // We counteract part of that effect by multiplying by the perspective ratio. - // If the label isn't pitched with the map, we do layout in viewport space, - // which makes labels in the distance larger relative to the features around - // them. We counteract part of that effect by dividing by the perspective ratio. - 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 = clamp( - 0.5 + 0.5 * distance_ratio, - 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles - 4.0); - - size *= perspective_ratio; - - float fontScale = size / 24.0; - - highp float symbol_rotation = 0.0; - if (u_rotate_symbol) { - // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units - // To figure out that angle in projected space, we draw a short horizontal line in tile - // space, project it, and measure its angle in projected space. - vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); - - vec2 a = projectedPoint.xy / projectedPoint.w; - vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; - - symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); - } - - highp float angle_sin = sin(segment_angle + symbol_rotation); - highp float angle_cos = cos(segment_angle + symbol_rotation); - mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); - - vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); - gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0); - float gamma_scale = gl_Position.w; - - vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; - float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); - - v_data0.xy = a_tex / u_texsize; - v_data0.zw = a_tex / u_texsize_icon; - v_data1 = vec4(gamma_scale, size, interpolated_fade_opacity, is_sdf); -} -)"; - static constexpr const char* fragment = R"(#define SDF_PX 8.0 - -#define SDF 1.0 -#define ICON 0.0 - -layout (std140) uniform SymbolTilePropsUBO { - bool u_is_text; - bool u_is_halo; - highp float u_gamma_scale; - lowp float tileprops_pad1; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -uniform sampler2D u_texture; -uniform sampler2D u_texture_icon; - -in vec4 v_data0; -in vec4 v_data1; - -#ifndef HAS_UNIFORM_u_fill_color -in highp vec4 fill_color; -#endif -#ifndef HAS_UNIFORM_u_halo_color -in highp vec4 halo_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#endif -#ifndef HAS_UNIFORM_u_halo_width -in lowp float halo_width; -#endif -#ifndef HAS_UNIFORM_u_halo_blur -in lowp float halo_blur; -#endif - -void main() { - highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color; - highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color; - highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; - highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width; - highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur; - - #ifdef HAS_UNIFORM_u_fill_color -highp vec4 fill_color = u_fill_color; -#endif - #ifdef HAS_UNIFORM_u_halo_color -highp vec4 halo_color = u_halo_color; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - #ifdef HAS_UNIFORM_u_halo_width -lowp float halo_width = u_halo_width; -#endif - #ifdef HAS_UNIFORM_u_halo_blur -lowp float halo_blur = u_halo_blur; -#endif - - float fade_opacity = v_data1[2]; - - if (v_data1.w == ICON) { - vec2 tex_icon = v_data0.zw; - lowp float alpha = opacity * fade_opacity; - fragColor = texture(u_texture_icon, tex_icon) * alpha; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif - return; - } - - vec2 tex = v_data0.xy; - - float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO; - - float gamma_scale = v_data1.x; - float size = v_data1.y; - - float fontScale = size / 24.0; - - lowp vec4 color = fill_color; - highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale); - lowp float buff = (256.0 - 64.0) / 256.0; - if (u_is_halo) { - color = halo_color; - gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale); - buff = (6.0 - halo_width / fontScale) / SDF_PX; - } - - lowp float dist = texture(u_texture, tex).a; - highp float gamma_scaled = gamma * gamma_scale; - highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - - fragColor = color * (alpha * opacity * fade_opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/fill.hpp b/include/mbgl/shaders/gl/fill.hpp index f1ed0e6f2..58e2ab57b 100644 --- a/include/mbgl/shaders/gl/fill.hpp +++ b/include/mbgl/shaders/gl/fill.hpp @@ -6,25 +6,35 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "FillProgram"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "FillShader"; + static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO { + highp mat4 u_matrix; + // Interpolations + highp float u_color_t; + highp float u_opacity_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; -uniform mat4 u_matrix; +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + +layout (location = 0) in vec2 a_pos; #ifndef HAS_UNIFORM_u_color -uniform lowp float u_color_t; layout (location = 1) in highp vec4 a_color; out highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 2) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { @@ -42,15 +52,20 @@ lowp float opacity = u_opacity; gl_Position = u_matrix * vec4(a_pos, 0, 1); } )"; - static constexpr const char* fragment = R"(#ifndef HAS_UNIFORM_u_color + static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + +#ifndef HAS_UNIFORM_u_color in highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { diff --git a/include/mbgl/shaders/gl/fill_extrusion.hpp b/include/mbgl/shaders/gl/fill_extrusion.hpp index afe1936e1..10a7d912f 100644 --- a/include/mbgl/shaders/gl/fill_extrusion.hpp +++ b/include/mbgl/shaders/gl/fill_extrusion.hpp @@ -6,36 +6,59 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "FillExtrusionProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec3 u_lightcolor; -uniform lowp vec3 u_lightpos; -uniform lowp float u_lightintensity; -uniform float u_vertical_gradient; -uniform lowp float u_opacity; - -layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "FillExtrusionShader"; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; layout (location = 1) in vec4 a_normal_ed; out vec4 v_color; +layout (std140) uniform FillExtrusionDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_height_factor; + highp float u_tile_ratio; + // Interpolations + highp float u_base_t; + highp float u_height_t; + highp float u_color_t; + highp float u_pattern_from_t; + highp float u_pattern_to_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform FillExtrusionTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillExtrusionPropsUBO { + highp vec4 u_color; + highp vec3 u_lightcolor; + lowp float props_pad1; + highp vec3 u_lightpos; + highp float u_base; + highp float u_height; + highp float u_lightintensity; + highp float u_vertical_gradient; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; + lowp float props_pad2; +}; + #ifndef HAS_UNIFORM_u_base -uniform lowp float u_base_t; layout (location = 2) in highp vec2 a_base; -#else -uniform highp float u_base; #endif #ifndef HAS_UNIFORM_u_height -uniform lowp float u_height_t; layout (location = 3) in highp vec2 a_height; -#else -uniform highp float u_height; #endif #ifndef HAS_UNIFORM_u_color -uniform lowp float u_color_t; layout (location = 4) in highp vec4 a_color; -#else -uniform highp vec4 u_color; #endif void main() { diff --git a/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp b/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp index a24c7b906..11f7e40c4 100644 --- a/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp +++ b/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp @@ -6,54 +6,81 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "FillExtrusionPatternProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform float u_height_factor; -uniform vec4 u_scale; -uniform float u_vertical_gradient; -uniform lowp float u_opacity; - -uniform vec3 u_lightcolor; -uniform lowp vec3 u_lightpos; -uniform lowp float u_lightintensity; - -layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "FillExtrusionPatternShader"; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; layout (location = 1) in vec4 a_normal_ed; out vec2 v_pos_a; out vec2 v_pos_b; out vec4 v_lighting; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform FillExtrusionDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_height_factor; + highp float u_tile_ratio; + // Interpolations + highp float u_base_t; + highp float u_height_t; + highp float u_color_t; + highp float u_pattern_from_t; + highp float u_pattern_to_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform FillExtrusionTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillExtrusionPropsUBO { + highp vec4 u_color; + highp vec3 u_lightcolor; + lowp float props_pad1; + highp vec3 u_lightpos; + highp float u_base; + highp float u_height; + highp float u_lightintensity; + highp float u_vertical_gradient; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; + lowp float props_pad2; +}; + #ifndef HAS_UNIFORM_u_base -uniform lowp float u_base_t; layout (location = 2) in lowp vec2 a_base; out lowp float base; -#else -uniform lowp float u_base; #endif #ifndef HAS_UNIFORM_u_height -uniform lowp float u_height_t; layout (location = 3) in lowp vec2 a_height; out lowp float height; -#else -uniform lowp float u_height; #endif #ifndef HAS_UNIFORM_u_pattern_from -uniform lowp float u_pattern_from_t; layout (location = 4) in mediump vec4 a_pattern_from; out mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -uniform lowp float u_pattern_to_t; layout (location = 5) in mediump vec4 a_pattern_to; out mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; #endif void main() { @@ -83,10 +110,10 @@ mediump vec4 pattern_to = u_pattern_to; vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; - float pixelRatio = u_scale.x; - float tileRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; + float pixelRatio = u_pixel_ratio; + float tileRatio = u_tile_ratio; + float fromScale = u_from_scale; + float toScale = u_to_scale; vec3 normal = a_normal_ed.xyz; float edgedistance = a_normal_ed.w; @@ -125,34 +152,47 @@ mediump vec4 pattern_to = u_pattern_to; v_lighting *= u_opacity; } )"; - static constexpr const char* fragment = R"(uniform vec2 u_texsize; -uniform float u_fade; - -uniform sampler2D u_image; - -in vec2 v_pos_a; + static constexpr const char* fragment = R"(in vec2 v_pos_a; in vec2 v_pos_b; in vec4 v_lighting; +layout (std140) uniform FillExtrusionTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillExtrusionPropsUBO { + highp vec4 u_color; + highp vec3 u_lightcolor; + lowp float props_pad1; + highp vec3 u_lightpos; + highp float u_base; + highp float u_height; + highp float u_lightintensity; + highp float u_vertical_gradient; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; + lowp float props_pad2; +}; + +uniform sampler2D u_image; + #ifndef HAS_UNIFORM_u_base in lowp float base; -#else -uniform lowp float u_base; #endif #ifndef HAS_UNIFORM_u_height in lowp float height; -#else -uniform lowp float u_height; #endif #ifndef HAS_UNIFORM_u_pattern_from in mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to in mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; #endif void main() { diff --git a/include/mbgl/shaders/gl/fill_outline.hpp b/include/mbgl/shaders/gl/fill_outline.hpp index 800829391..ae157ae5f 100644 --- a/include/mbgl/shaders/gl/fill_outline.hpp +++ b/include/mbgl/shaders/gl/fill_outline.hpp @@ -6,28 +6,49 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "FillOutlineProgram"; - static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "FillOutlineShader"; + static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; -uniform mat4 u_matrix; -uniform vec2 u_world; +layout (std140) uniform FillOutlineDrawableUBO { + highp mat4 u_matrix; + // Interpolations + highp float u_outline_color_t; + highp float u_opacity_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + +layout (location = 0) in vec2 a_pos; out vec2 v_pos; #ifndef HAS_UNIFORM_u_outline_color -uniform lowp float u_outline_color_t; layout (location = 1) in highp vec4 a_outline_color; out highp vec4 outline_color; -#else -uniform highp vec4 u_outline_color; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 2) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { @@ -43,20 +64,25 @@ lowp float opacity = u_opacity; #endif gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; + v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; } )"; - static constexpr const char* fragment = R"(in vec2 v_pos; + static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + +in vec2 v_pos; #ifndef HAS_UNIFORM_u_outline_color in highp vec4 outline_color; -#else -uniform highp vec4 u_outline_color; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { diff --git a/include/mbgl/shaders/gl/fill_outline_pattern.hpp b/include/mbgl/shaders/gl/fill_outline_pattern.hpp index ca6c80aec..f197a5631 100644 --- a/include/mbgl/shaders/gl/fill_outline_pattern.hpp +++ b/include/mbgl/shaders/gl/fill_outline_pattern.hpp @@ -6,13 +6,47 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "FillOutlinePatternProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec2 u_world; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform vec4 u_scale; +struct ShaderSource { + static constexpr const char* name = "FillOutlinePatternShader"; + static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform FillOutlinePatternDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_tile_ratio; + // Interpolations + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; +}; + +layout (std140) uniform FillOutlinePatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; layout (location = 0) in vec2 a_pos; @@ -21,25 +55,16 @@ out vec2 v_pos_b; out vec2 v_pos; #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 1) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_pattern_from -uniform lowp float u_pattern_from_t; -layout (location = 2) in mediump vec4 a_pattern_from; -out mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; +layout (location = 2) in lowp vec4 a_pattern_from; +out lowp vec4 pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -uniform lowp float u_pattern_to_t; -layout (location = 3) in mediump vec4 a_pattern_to; -out mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; +layout (location = 3) in lowp vec4 a_pattern_to; +out lowp vec4 pattern_to; #endif void main() { @@ -64,10 +89,10 @@ mediump vec4 pattern_to = u_pattern_to; vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; - float pixelRatio = u_scale.x; - float tileRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; + float pixelRatio = u_pixel_ratio; + float tileRatio = u_tile_ratio; + float fromScale = u_from_scale; + float toScale = u_to_scale; gl_Position = u_matrix * vec4(a_pos, 0, 1); @@ -77,13 +102,27 @@ mediump vec4 pattern_to = u_pattern_to; v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, a_pos); v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, a_pos); - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; + v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; } )"; - static constexpr const char* fragment = R"( -uniform vec2 u_texsize; + static constexpr const char* fragment = R"(layout (std140) uniform FillOutlinePatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + uniform sampler2D u_image; -uniform float u_fade; in vec2 v_pos_a; in vec2 v_pos_b; @@ -91,18 +130,12 @@ in vec2 v_pos; #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_pattern_from -in mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; +in lowp vec4 pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -in mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; +in lowp vec4 pattern_to; #endif void main() { diff --git a/include/mbgl/shaders/gl/drawable_fill_outline_triangulated.hpp b/include/mbgl/shaders/gl/fill_outline_triangulated.hpp similarity index 100% rename from include/mbgl/shaders/gl/drawable_fill_outline_triangulated.hpp rename to include/mbgl/shaders/gl/fill_outline_triangulated.hpp diff --git a/include/mbgl/shaders/gl/fill_pattern.hpp b/include/mbgl/shaders/gl/fill_pattern.hpp index 40b7cb18e..fecf17eda 100644 --- a/include/mbgl/shaders/gl/fill_pattern.hpp +++ b/include/mbgl/shaders/gl/fill_pattern.hpp @@ -6,12 +6,47 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "FillPatternProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform vec4 u_scale; +struct ShaderSource { + static constexpr const char* name = "FillPatternShader"; + static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform FillPatternDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_tile_ratio; + // Interpolations + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; +}; + +layout (std140) uniform FillPatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; layout (location = 0) in vec2 a_pos; @@ -19,25 +54,16 @@ out vec2 v_pos_a; out vec2 v_pos_b; #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 1) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_pattern_from -uniform lowp float u_pattern_from_t; -layout (location = 2) in mediump vec4 a_pattern_from; -out mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; +layout (location = 2) in lowp vec4 a_pattern_from; +out lowp vec4 pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -uniform lowp float u_pattern_to_t; -layout (location = 3) in mediump vec4 a_pattern_to; -out mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; +layout (location = 3) in lowp vec4 a_pattern_to; +out lowp vec4 pattern_to; #endif void main() { @@ -62,10 +88,10 @@ mediump vec4 pattern_to = u_pattern_to; vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; - float pixelRatio = u_scale.x; - float tileZoomRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; + float pixelRatio = u_pixel_ratio; + float tileZoomRatio = u_tile_ratio; + float fromScale = u_from_scale; + float toScale = u_to_scale; vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); @@ -75,8 +101,22 @@ mediump vec4 pattern_to = u_pattern_to; v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos); } )"; - static constexpr const char* fragment = R"(uniform vec2 u_texsize; -uniform float u_fade; + static constexpr const char* fragment = R"(layout (std140) uniform FillPatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; uniform sampler2D u_image; @@ -85,18 +125,12 @@ in vec2 v_pos_b; #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_pattern_from -in mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; +in lowp vec4 pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -in mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; +in lowp vec4 pattern_to; #endif void main() { @@ -115,6 +149,10 @@ mediump vec4 pattern_to = u_pattern_to; vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; + if (u_texsize.x < 1.0 || u_texsize.y < 1.0) { + discard; + } + vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); vec4 color1 = texture(u_image, pos); diff --git a/include/mbgl/shaders/gl/heatmap.hpp b/include/mbgl/shaders/gl/heatmap.hpp index ea0aeab9f..9b93c798e 100644 --- a/include/mbgl/shaders/gl/heatmap.hpp +++ b/include/mbgl/shaders/gl/heatmap.hpp @@ -6,28 +6,33 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "HeatmapProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform float u_extrude_scale; -uniform float u_opacity; -uniform float u_intensity; - -layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "HeatmapShader"; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; out vec2 v_extrude; +layout (std140) uniform HeatmapDrawableUBO { + highp mat4 u_matrix; + highp float u_extrude_scale; + // Interpolations + lowp float u_weight_t; + lowp float u_radius_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform HeatmapEvaluatedPropsUBO { + highp float u_weight; + highp float u_radius; + highp float u_intensity; + lowp float props_pad1; +}; + #ifndef HAS_UNIFORM_u_weight -uniform lowp float u_weight_t; layout (location = 1) in highp vec2 a_weight; out highp float weight; -#else -uniform highp float u_weight; #endif #ifndef HAS_UNIFORM_u_radius -uniform lowp float u_radius_t; layout (location = 2) in mediump vec2 a_radius; -#else -uniform mediump float u_radius; #endif // Effective "0" in the kernel density texture to adjust the kernel size to; @@ -80,14 +85,17 @@ mediump float radius = u_radius; gl_Position = u_matrix * pos; } )"; - static constexpr const char* fragment = R"(uniform highp float u_intensity; + static constexpr const char* fragment = R"(in vec2 v_extrude; -in vec2 v_extrude; +layout (std140) uniform HeatmapEvaluatedPropsUBO { + highp float u_weight; + highp float u_radius; + highp float u_intensity; + lowp float props_pad1; +}; #ifndef HAS_UNIFORM_u_weight in highp float weight; -#else -uniform highp float u_weight; #endif // Gaussian kernel coefficient: 1 / sqrt(2 * PI) diff --git a/include/mbgl/shaders/gl/heatmap_texture.hpp b/include/mbgl/shaders/gl/heatmap_texture.hpp index 5115a2897..19317a2d6 100644 --- a/include/mbgl/shaders/gl/heatmap_texture.hpp +++ b/include/mbgl/shaders/gl/heatmap_texture.hpp @@ -6,24 +6,49 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "HeatmapTextureProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec2 u_world; -layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "HeatmapTextureShader"; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; out vec2 v_pos; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform HeatmapTexturePropsUBO { + highp mat4 u_matrix; + highp float u_opacity; + lowp float props_pad1; + lowp float props_pad2; + lowp float props_pad3; +}; + void main() { - gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); + gl_Position = u_matrix * vec4(a_pos * u_world_size, 0, 1); v_pos.x = a_pos.x; v_pos.y = 1.0 - a_pos.y; } )"; - static constexpr const char* fragment = R"(uniform sampler2D u_image; + static constexpr const char* fragment = R"(in vec2 v_pos; +uniform sampler2D u_image; uniform sampler2D u_color_ramp; -uniform float u_opacity; -in vec2 v_pos; + +layout (std140) uniform HeatmapTexturePropsUBO { + highp mat4 u_matrix; + highp float u_opacity; + lowp float props_pad1; + lowp float props_pad2; + lowp float props_pad3; +}; void main() { float t = texture(u_image, v_pos).r; diff --git a/include/mbgl/shaders/gl/hillshade.hpp b/include/mbgl/shaders/gl/hillshade.hpp index 67b69950c..8d1865380 100644 --- a/include/mbgl/shaders/gl/hillshade.hpp +++ b/include/mbgl/shaders/gl/hillshade.hpp @@ -6,13 +6,15 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "HillshadeProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; - -layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "HillshadeShader"; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_texture_pos; +layout (std140) uniform HillshadeDrawableUBO { + highp mat4 u_matrix; +}; + out vec2 v_pos; void main() { @@ -20,14 +22,19 @@ void main() { v_pos = a_texture_pos / 8192.0; } )"; - static constexpr const char* fragment = R"(uniform sampler2D u_image; -in vec2 v_pos; + static constexpr const char* fragment = R"(in vec2 v_pos; +uniform sampler2D u_image; -uniform vec2 u_latrange; -uniform vec2 u_light; -uniform vec4 u_shadow; -uniform vec4 u_highlight; -uniform vec4 u_accent; +layout (std140) uniform HillshadeTilePropsUBO { + highp vec2 u_latrange; + highp vec2 u_light; +}; + +layout (std140) uniform HillshadeEvaluatedPropsUBO { + highp vec4 u_highlight; + highp vec4 u_shadow; + highp vec4 u_accent; +}; #define PI 3.141592653589793 diff --git a/include/mbgl/shaders/gl/hillshade_prepare.hpp b/include/mbgl/shaders/gl/hillshade_prepare.hpp index ae1abf2f9..2a2bf01b5 100644 --- a/include/mbgl/shaders/gl/hillshade_prepare.hpp +++ b/include/mbgl/shaders/gl/hillshade_prepare.hpp @@ -6,14 +6,22 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "HillshadePrepareProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec2 u_dimension; - -layout (location = 0) in vec2 a_pos; +struct ShaderSource { + static constexpr const char* name = "HillshadePrepareShader"; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_texture_pos; +layout (std140) uniform HillshadePrepareDrawableUBO { + highp mat4 u_matrix; +}; + +layout (std140) uniform HillshadePrepareTilePropsUBO { + highp vec4 u_unpack; + highp vec2 u_dimension; + highp float u_zoom; + highp float u_maxzoom; +}; + out vec2 v_pos; void main() { @@ -28,12 +36,15 @@ void main() { precision highp float; #endif -uniform sampler2D u_image; in vec2 v_pos; -uniform vec2 u_dimension; -uniform float u_zoom; -uniform float u_maxzoom; -uniform vec4 u_unpack; +uniform sampler2D u_image; + +layout (std140) uniform HillshadePrepareTilePropsUBO { + highp vec4 u_unpack; + highp vec2 u_dimension; + highp float u_zoom; + highp float u_maxzoom; +}; float getElevation(vec2 coord, float bias) { // Convert encoded elevation value to meters diff --git a/include/mbgl/shaders/gl/line.hpp b/include/mbgl/shaders/gl/line.hpp index 3993a8a32..1f0935817 100644 --- a/include/mbgl/shaders/gl/line.hpp +++ b/include/mbgl/shaders/gl/line.hpp @@ -6,8 +6,8 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "LineProgram"; +struct ShaderSource { + static constexpr const char* name = "LineShader"; static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 // the maximum allowed miter limit is 2.0 at the moment. the extrude normal is // stored in a byte (-128..127). we scale regular normals up to length 63, but @@ -19,10 +19,42 @@ struct ShaderSource { layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform mediump float u_ratio; -uniform vec2 u_units_to_pixels; -uniform lowp float u_device_pixel_ratio; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform LineDrawableUBO { + highp mat4 u_matrix; + mediump float u_ratio; + // Interpolations + lowp float u_color_t; + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_gapwidth_t; + lowp float u_offset_t; + lowp float u_width_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -30,43 +62,25 @@ out float v_gamma_scale; out highp float v_linesofar; #ifndef HAS_UNIFORM_u_color -uniform lowp float u_color_t; layout (location = 2) in highp vec4 a_color; out highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_blur -uniform lowp float u_blur_t; layout (location = 3) in lowp vec2 a_blur; out lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 4) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_gapwidth -uniform lowp float u_gapwidth_t; layout (location = 5) in mediump vec2 a_gapwidth; -#else -uniform mediump float u_gapwidth; #endif #ifndef HAS_UNIFORM_u_offset -uniform lowp float u_offset_t; layout (location = 6) in lowp vec2 a_offset; -#else -uniform lowp float u_offset; #endif #ifndef HAS_UNIFORM_u_width -uniform lowp float u_width_t; layout (location = 7) in mediump vec2 a_width; -#else -uniform mediump float u_width; #endif void main() { @@ -103,7 +117,7 @@ mediump float width = u_width; // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; @@ -151,7 +165,17 @@ mediump float width = u_width; v_width2 = vec2(outset, inset); } )"; - static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio; + static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; in vec2 v_width2; in vec2 v_normal; @@ -159,18 +183,12 @@ in float v_gamma_scale; #ifndef HAS_UNIFORM_u_color in highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_blur in lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { @@ -190,7 +208,7 @@ lowp float opacity = u_opacity; // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); fragColor = color * (alpha * opacity); diff --git a/include/mbgl/shaders/gl/line_gradient.hpp b/include/mbgl/shaders/gl/line_gradient.hpp index 74f0d105a..c77e020c4 100644 --- a/include/mbgl/shaders/gl/line_gradient.hpp +++ b/include/mbgl/shaders/gl/line_gradient.hpp @@ -6,8 +6,8 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "LineGradientProgram"; +struct ShaderSource { + static constexpr const char* name = "LineGradientShader"; static constexpr const char* vertex = R"( // the attribute conveying progress along a line is scaled to [0, 2^15) #define MAX_LINE_DISTANCE 32767.0 @@ -23,10 +23,42 @@ struct ShaderSource { layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform mediump float u_ratio; -uniform lowp float u_device_pixel_ratio; -uniform vec2 u_units_to_pixels; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform LineGradientDrawableUBO { + highp mat4 u_matrix; + mediump float u_ratio; + // Interpolations + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_gapwidth_t; + lowp float u_offset_t; + lowp float u_width_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -34,36 +66,21 @@ out float v_gamma_scale; out highp float v_lineprogress; #ifndef HAS_UNIFORM_u_blur -uniform lowp float u_blur_t; layout (location = 2) in lowp vec2 a_blur; out lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 3) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_gapwidth -uniform lowp float u_gapwidth_t; layout (location = 4) in mediump vec2 a_gapwidth; -#else -uniform mediump float u_gapwidth; #endif #ifndef HAS_UNIFORM_u_offset -uniform lowp float u_offset_t; layout (location = 5) in lowp vec2 a_offset; -#else -uniform lowp float u_offset; #endif #ifndef HAS_UNIFORM_u_width -uniform lowp float u_width_t; layout (location = 6) in mediump vec2 a_width; -#else -uniform mediump float u_width; #endif void main() { @@ -95,7 +112,7 @@ mediump float width = u_width; // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; @@ -143,7 +160,18 @@ mediump float width = u_width; v_width2 = vec2(outset, inset); } )"; - static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio; + static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; + uniform sampler2D u_image; in vec2 v_width2; @@ -153,13 +181,9 @@ in highp float v_lineprogress; #ifndef HAS_UNIFORM_u_blur in lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { @@ -176,7 +200,7 @@ lowp float opacity = u_opacity; // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); // For gradient lines, v_lineprogress is the ratio along the entire line, diff --git a/include/mbgl/shaders/gl/line_pattern.hpp b/include/mbgl/shaders/gl/line_pattern.hpp index 46a3a0cd1..ea4b8809f 100644 --- a/include/mbgl/shaders/gl/line_pattern.hpp +++ b/include/mbgl/shaders/gl/line_pattern.hpp @@ -6,8 +6,8 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "LinePatternProgram"; +struct ShaderSource { + static constexpr const char* name = "LinePatternShader"; static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 // the maximum allowed miter limit is 2.0 at the moment. the extrude normal is // stored in a byte (-128..127). we scale regular normals up to length 63, but @@ -23,10 +23,50 @@ struct ShaderSource { layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform vec2 u_units_to_pixels; -uniform mediump float u_ratio; -uniform lowp float u_device_pixel_ratio; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; +layout (std140) uniform LinePatternDrawableUBO { + highp mat4 u_matrix; + mediump float u_ratio; + // Interpolations + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_offset_t; + lowp float u_gapwidth_t; + lowp float u_width_t; + lowp float u_pattern_from_t; + lowp float u_pattern_to_t; +}; + +layout (std140) uniform LinePatternTilePropsUBO { + lowp vec4 u_pattern_from; + lowp vec4 u_pattern_to; + mediump vec4 u_scale; + highp vec2 u_texsize; + highp float u_fade; + lowp float tileprops_pad1; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -34,50 +74,29 @@ out float v_linesofar; out float v_gamma_scale; #ifndef HAS_UNIFORM_u_blur -uniform lowp float u_blur_t; layout (location = 2) in lowp vec2 a_blur; out lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 3) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_offset -uniform lowp float u_offset_t; layout (location = 4) in lowp vec2 a_offset; -#else -uniform lowp float u_offset; #endif #ifndef HAS_UNIFORM_u_gapwidth -uniform lowp float u_gapwidth_t; layout (location = 5) in mediump vec2 a_gapwidth; -#else -uniform mediump float u_gapwidth; #endif #ifndef HAS_UNIFORM_u_width -uniform lowp float u_width_t; layout (location = 6) in mediump vec2 a_width; -#else -uniform mediump float u_width; #endif #ifndef HAS_UNIFORM_u_pattern_from -uniform lowp float u_pattern_from_t; -layout (location = 7) in mediump vec4 a_pattern_from; -out mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; +layout (location = 7) in lowp vec4 a_pattern_from; +out lowp vec4 pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -uniform lowp float u_pattern_to_t; -layout (location = 8) in mediump vec4 a_pattern_to; -out mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; +layout (location = 8) in lowp vec4 a_pattern_to; +out lowp vec4 pattern_to; #endif void main() { @@ -119,7 +138,7 @@ mediump vec4 pattern_to = u_pattern_to; // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; @@ -167,10 +186,26 @@ mediump vec4 pattern_to = u_pattern_to; v_width2 = vec2(outset, inset); } )"; - static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio; -uniform vec2 u_texsize; -uniform float u_fade; -uniform mediump vec4 u_scale; + static constexpr const char* fragment = R"(layout (std140) uniform LinePatternTilePropsUBO { + lowp vec4 u_pattern_from; + lowp vec4 u_pattern_to; + mediump vec4 u_scale; + highp vec2 u_texsize; + highp float u_fade; + lowp float tileprops_pad1; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; uniform sampler2D u_image; @@ -180,24 +215,16 @@ in float v_linesofar; in float v_gamma_scale; #ifndef HAS_UNIFORM_u_pattern_from -in mediump vec4 pattern_from; -#else -uniform mediump vec4 u_pattern_from; +in lowp vec4 pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -in mediump vec4 pattern_to; -#else -uniform mediump vec4 u_pattern_to; +in lowp vec4 pattern_to; #endif #ifndef HAS_UNIFORM_u_blur in lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { @@ -207,6 +234,7 @@ mediump vec4 pattern_from = u_pattern_from; #ifdef HAS_UNIFORM_u_pattern_to mediump vec4 pattern_to = u_pattern_to; #endif + #ifdef HAS_UNIFORM_u_blur lowp float blur = u_blur; #endif @@ -236,7 +264,7 @@ lowp float opacity = u_opacity; // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); float x_a = mod(v_linesofar / pattern_size_a.x, 1.0); diff --git a/include/mbgl/shaders/gl/line_sdf.hpp b/include/mbgl/shaders/gl/line_sdf.hpp index 830a2f03a..7772658f2 100644 --- a/include/mbgl/shaders/gl/line_sdf.hpp +++ b/include/mbgl/shaders/gl/line_sdf.hpp @@ -6,8 +6,8 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "LineSDFProgram"; +struct ShaderSource { + static constexpr const char* name = "LineSDFShader"; static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 // the maximum allowed miter limit is 2.0 at the moment. the extrude normal is // stored in a byte (-128..127). we scale regular normals up to length 63, but @@ -23,14 +23,48 @@ struct ShaderSource { layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform mediump float u_ratio; -uniform lowp float u_device_pixel_ratio; -uniform vec2 u_patternscale_a; -uniform float u_tex_y_a; -uniform vec2 u_patternscale_b; -uniform float u_tex_y_b; -uniform vec2 u_units_to_pixels; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform LineSDFDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_patternscale_a; + highp vec2 u_patternscale_b; + highp float u_tex_y_a; + highp float u_tex_y_b; + mediump float u_ratio; + // Interpolations + lowp float u_color_t; + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_gapwidth_t; + lowp float u_offset_t; + lowp float u_width_t; + lowp float u_floorwidth_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -39,51 +73,30 @@ out vec2 v_tex_b; out float v_gamma_scale; #ifndef HAS_UNIFORM_u_color -uniform lowp float u_color_t; layout (location = 2) in highp vec4 a_color; out highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_blur -uniform lowp float u_blur_t; layout (location = 3) in lowp vec2 a_blur; out lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 4) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_gapwidth -uniform lowp float u_gapwidth_t; layout (location = 5) in mediump vec2 a_gapwidth; -#else -uniform mediump float u_gapwidth; #endif #ifndef HAS_UNIFORM_u_offset -uniform lowp float u_offset_t; layout (location = 6) in lowp vec2 a_offset; -#else -uniform lowp float u_offset; #endif #ifndef HAS_UNIFORM_u_width -uniform lowp float u_width_t; layout (location = 7) in mediump vec2 a_width; out mediump float width; -#else -uniform mediump float u_width; #endif #ifndef HAS_UNIFORM_u_floorwidth -uniform lowp float u_floorwidth_t; layout (location = 8) in lowp vec2 a_floorwidth; out lowp float floorwidth; -#else -uniform lowp float u_floorwidth; #endif void main() { @@ -125,7 +138,7 @@ lowp float floorwidth = u_floorwidth; // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; @@ -175,11 +188,26 @@ lowp float floorwidth = u_floorwidth; v_width2 = vec2(outset, inset); } )"; - static constexpr const char* fragment = R"( -uniform lowp float u_device_pixel_ratio; + static constexpr const char* fragment = R"(layout (std140) uniform LineSDFTilePropsUBO { + highp float u_sdfgamma; + highp float u_mix; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; + uniform sampler2D u_image; -uniform float u_sdfgamma; -uniform float u_mix; in vec2 v_normal; in vec2 v_width2; @@ -189,28 +217,18 @@ in float v_gamma_scale; #ifndef HAS_UNIFORM_u_color in highp vec4 color; -#else -uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_blur in lowp float blur; -#else -uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_width in mediump float width; -#else -uniform mediump float u_width; #endif #ifndef HAS_UNIFORM_u_floorwidth in lowp float floorwidth; -#else -uniform lowp float u_floorwidth; #endif void main() { @@ -236,7 +254,7 @@ lowp float floorwidth = u_floorwidth; // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); float sdfdist_a = texture(u_image, v_tex_a).a; diff --git a/include/mbgl/shaders/gl/drawable_location_indicator.hpp b/include/mbgl/shaders/gl/location_indicator.hpp similarity index 98% rename from include/mbgl/shaders/gl/drawable_location_indicator.hpp rename to include/mbgl/shaders/gl/location_indicator.hpp index 5d0b261f9..3316f6c90 100644 --- a/include/mbgl/shaders/gl/drawable_location_indicator.hpp +++ b/include/mbgl/shaders/gl/location_indicator.hpp @@ -17,7 +17,8 @@ layout(location = 0) in vec2 a_pos; void main() { gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0); -})"; +} +)"; static constexpr const char* fragment = R"(layout (std140) uniform LocationIndicatorDrawableUBO { mat4 u_matrix; vec4 u_color; @@ -25,7 +26,8 @@ void main() { void main() { fragColor = u_color; -})"; +} +)"; }; } // namespace shaders diff --git a/include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp b/include/mbgl/shaders/gl/location_indicator_textured.hpp similarity index 98% rename from include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp rename to include/mbgl/shaders/gl/location_indicator_textured.hpp index 2993936c4..f0dc0cfe9 100644 --- a/include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp +++ b/include/mbgl/shaders/gl/location_indicator_textured.hpp @@ -21,7 +21,8 @@ out vec2 frag_uv; void main() { frag_uv = a_uv; gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0); -})"; +} +)"; static constexpr const char* fragment = R"(layout (std140) uniform LocationIndicatorDrawableUBO { mat4 u_matrix; vec4 u_color; @@ -32,7 +33,8 @@ uniform sampler2D u_image; void main() { fragColor = texture(u_image, frag_uv); -})"; +} +)"; }; } // namespace shaders diff --git a/include/mbgl/shaders/gl/raster.hpp b/include/mbgl/shaders/gl/raster.hpp index 6320dad54..ee2865764 100644 --- a/include/mbgl/shaders/gl/raster.hpp +++ b/include/mbgl/shaders/gl/raster.hpp @@ -6,12 +6,25 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "RasterProgram"; - static constexpr const char* vertex = R"(uniform mat4 u_matrix; -uniform vec2 u_tl_parent; -uniform float u_scale_parent; -uniform float u_buffer_scale; +struct ShaderSource { + static constexpr const char* name = "RasterShader"; + static constexpr const char* vertex = R"(layout (std140) uniform RasterDrawableUBO { + highp mat4 u_matrix; +}; +layout (std140) uniform RasterEvaluatedPropsUBO { + highp vec3 u_spin_weights; + highp vec2 u_tl_parent; + highp float u_scale_parent; + highp float u_buffer_scale; + highp float u_fade_t; + highp float u_opacity; + highp float u_brightness_low; + highp float u_brightness_high; + highp float u_saturation_factor; + highp float u_contrast_factor; + lowp float props_pad1; + lowp float props_pad2; +}; layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_texture_pos; @@ -30,20 +43,26 @@ void main() { v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent; } )"; - static constexpr const char* fragment = R"(uniform float u_fade_t; -uniform float u_opacity; + static constexpr const char* fragment = R"(layout (std140) uniform RasterEvaluatedPropsUBO { + highp vec3 u_spin_weights; + highp vec2 u_tl_parent; + highp float u_scale_parent; + highp float u_buffer_scale; + highp float u_fade_t; + highp float u_opacity; + highp float u_brightness_low; + highp float u_brightness_high; + highp float u_saturation_factor; + highp float u_contrast_factor; + lowp float props_pad1; + lowp float props_pad2; +}; uniform sampler2D u_image0; uniform sampler2D u_image1; + in vec2 v_pos0; in vec2 v_pos1; -uniform float u_brightness_low; -uniform float u_brightness_high; - -uniform float u_saturation_factor; -uniform float u_contrast_factor; -uniform vec3 u_spin_weights; - void main() { // read and cross-fade colors from the main and parent tiles diff --git a/include/mbgl/shaders/gl/symbol_icon.hpp b/include/mbgl/shaders/gl/symbol_icon.hpp index bf96c3952..9ac73b34a 100644 --- a/include/mbgl/shaders/gl/symbol_icon.hpp +++ b/include/mbgl/shaders/gl/symbol_icon.hpp @@ -6,45 +6,77 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "SymbolIconProgram"; +struct ShaderSource { + static constexpr const char* name = "SymbolIconShader"; static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset; layout (location = 1) in vec4 a_data; layout (location = 2) in vec4 a_pixeloffset; layout (location = 3) in vec3 a_projected_pos; layout (location = 4) in float a_fade_opacity; -uniform bool u_is_size_zoom_constant; -uniform bool u_is_size_feature_constant; -uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function -uniform highp float u_size; // used when size is both zoom and feature constant -uniform highp float u_camera_to_center_distance; -uniform highp float u_pitch; -uniform bool u_rotate_symbol; -uniform highp float u_aspect_ratio; -uniform float u_fade_change; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; -uniform mat4 u_matrix; -uniform mat4 u_label_plane_matrix; -uniform mat4 u_coord_matrix; +layout (std140) uniform SymbolDrawableUBO { + highp mat4 u_matrix; + highp mat4 u_label_plane_matrix; + highp mat4 u_coord_matrix; -uniform bool u_is_text; -uniform bool u_pitch_with_map; + highp vec2 u_texsize; + highp vec2 u_texsize_icon; -uniform vec2 u_texsize; + bool u_is_text_prop; + bool u_rotate_symbol; + bool u_pitch_with_map; + bool u_is_size_zoom_constant; + bool u_is_size_feature_constant; + + highp float u_size_t; // used to interpolate between zoom stops when size is a composite function + highp float u_size; // used when size is both zoom and feature constant + + // Interpolations + highp float u_fill_color_t; + highp float u_halo_color_t; + highp float u_opacity_t; + highp float u_halo_width_t; + highp float u_halo_blur_t; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; out vec2 v_tex; out float v_fade_opacity; #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 5) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { + highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; + #ifndef HAS_UNIFORM_u_opacity opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else @@ -85,7 +117,7 @@ lowp float opacity = u_opacity; size *= perspective_ratio; - float fontScale = u_is_text ? size / 24.0 : size; + float fontScale = u_is_text_prop ? size / 24.0 : size; highp float symbol_rotation = 0.0; if (u_rotate_symbol) { @@ -107,22 +139,44 @@ lowp float opacity = u_opacity; v_tex = a_tex / u_texsize; vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); } )"; static constexpr const char* fragment = R"(uniform sampler2D u_texture; +layout (std140) uniform SymbolTilePropsUBO { + bool u_is_text; + bool u_is_halo; + highp float u_gamma_scale; + lowp float tileprops_pad1; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; + in vec2 v_tex; in float v_fade_opacity; #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif void main() { + highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; + #ifdef HAS_UNIFORM_u_opacity lowp float opacity = u_opacity; #endif diff --git a/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp b/include/mbgl/shaders/gl/symbol_sdf.hpp similarity index 100% rename from include/mbgl/shaders/gl/drawable_symbol_sdf.hpp rename to include/mbgl/shaders/gl/symbol_sdf.hpp diff --git a/include/mbgl/shaders/gl/symbol_sdf_icon.hpp b/include/mbgl/shaders/gl/symbol_sdf_icon.hpp deleted file mode 100644 index 6094108c8..000000000 --- a/include/mbgl/shaders/gl/symbol_sdf_icon.hpp +++ /dev/null @@ -1,261 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "SymbolSDFIconProgram"; - static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset; -layout (location = 1) in vec4 a_data; -layout (location = 2) in vec4 a_pixeloffset; -layout (location = 3) in vec3 a_projected_pos; -layout (location = 4) in float a_fade_opacity; - -// contents of a_size vary based on the type of property value -// used for {text,icon}-size. -// For constants, a_size is disabled. -// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature. -// For composite functions: -// [ text-size(lowerZoomStop, feature), -// text-size(upperZoomStop, feature) ] -uniform bool u_is_size_zoom_constant; -uniform bool u_is_size_feature_constant; -uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function -uniform highp float u_size; // used when size is both zoom and feature constant -uniform mat4 u_matrix; -uniform mat4 u_label_plane_matrix; -uniform mat4 u_coord_matrix; -uniform bool u_is_text; -uniform bool u_pitch_with_map; -uniform highp float u_pitch; -uniform bool u_rotate_symbol; -uniform highp float u_aspect_ratio; -uniform highp float u_camera_to_center_distance; -uniform float u_fade_change; -uniform vec2 u_texsize; - -out vec2 v_data0; -out vec3 v_data1; - -#ifndef HAS_UNIFORM_u_fill_color -uniform lowp float u_fill_color_t; -layout (location = 5) in highp vec4 a_fill_color; -out highp vec4 fill_color; -#else -uniform highp vec4 u_fill_color; -#endif -#ifndef HAS_UNIFORM_u_halo_color -uniform lowp float u_halo_color_t; -layout (location = 6) in highp vec4 a_halo_color; -out highp vec4 halo_color; -#else -uniform highp vec4 u_halo_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; -layout (location = 7) in lowp vec2 a_opacity; -out lowp float opacity; -#else -uniform lowp float u_opacity; -#endif -#ifndef HAS_UNIFORM_u_halo_width -uniform lowp float u_halo_width_t; -layout (location = 8) in lowp vec2 a_halo_width; -out lowp float halo_width; -#else -uniform lowp float u_halo_width; -#endif -#ifndef HAS_UNIFORM_u_halo_blur -uniform lowp float u_halo_blur_t; -layout (location = 9) in lowp vec2 a_halo_blur; -out lowp float halo_blur; -#else -uniform lowp float u_halo_blur; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_fill_color -fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); -#else -highp vec4 fill_color = u_fill_color; -#endif - #ifndef HAS_UNIFORM_u_halo_color -halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); -#else -highp vec4 halo_color = u_halo_color; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_halo_width -halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); -#else -lowp float halo_width = u_halo_width; -#endif - #ifndef HAS_UNIFORM_u_halo_blur -halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); -#else -lowp float halo_blur = u_halo_blur; -#endif - - vec2 a_pos = a_pos_offset.xy; - vec2 a_offset = a_pos_offset.zw; - - vec2 a_tex = a_data.xy; - vec2 a_size = a_data.zw; - - float a_size_min = floor(a_size[0] * 0.5); - vec2 a_pxoffset = a_pixeloffset.xy; - - highp float segment_angle = -a_projected_pos[2]; - float size; - - if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = mix(a_size_min, a_size[1], u_size_t) / 128.0; - } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = a_size_min / 128.0; - } else { - size = u_size; - } - - vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1); - highp float camera_to_anchor_distance = projectedPoint.w; - // If the label is pitched with the map, layout is done in pitched space, - // which makes labels in the distance smaller relative to viewport space. - // We counteract part of that effect by multiplying by the perspective ratio. - // If the label isn't pitched with the map, we do layout in viewport space, - // which makes labels in the distance larger relative to the features around - // them. We counteract part of that effect by dividing by the perspective ratio. - 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 = clamp( - 0.5 + 0.5 * distance_ratio, - 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles - 4.0); - - size *= perspective_ratio; - - float fontScale = u_is_text ? size / 24.0 : size; - - highp float symbol_rotation = 0.0; - if (u_rotate_symbol) { - // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units - // To figure out that angle in projected space, we draw a short horizontal line in tile - // space, project it, and measure its angle in projected space. - vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); - - vec2 a = projectedPoint.xy / projectedPoint.w; - vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; - - symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); - } - - highp float angle_sin = sin(segment_angle + symbol_rotation); - highp float angle_cos = cos(segment_angle + symbol_rotation); - mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); - - vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); - gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset), 0.0, 1.0); - float gamma_scale = gl_Position.w; - - vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; - float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); - - v_data0 = a_tex / u_texsize; - v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity); -} -)"; - static constexpr const char* fragment = R"(#define SDF_PX 8.0 - -uniform bool u_is_halo; -uniform sampler2D u_texture; -uniform highp float u_gamma_scale; -uniform lowp float u_device_pixel_ratio; -uniform bool u_is_text; - -in vec2 v_data0; -in vec3 v_data1; - -#ifndef HAS_UNIFORM_u_fill_color -in highp vec4 fill_color; -#else -uniform highp vec4 u_fill_color; -#endif -#ifndef HAS_UNIFORM_u_halo_color -in highp vec4 halo_color; -#else -uniform highp vec4 u_halo_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#else -uniform lowp float u_opacity; -#endif -#ifndef HAS_UNIFORM_u_halo_width -in lowp float halo_width; -#else -uniform lowp float u_halo_width; -#endif -#ifndef HAS_UNIFORM_u_halo_blur -in lowp float halo_blur; -#else -uniform lowp float u_halo_blur; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_fill_color -highp vec4 fill_color = u_fill_color; -#endif - #ifdef HAS_UNIFORM_u_halo_color -highp vec4 halo_color = u_halo_color; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - #ifdef HAS_UNIFORM_u_halo_width -lowp float halo_width = u_halo_width; -#endif - #ifdef HAS_UNIFORM_u_halo_blur -lowp float halo_blur = u_halo_blur; -#endif - - float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; - - vec2 tex = v_data0.xy; - float gamma_scale = v_data1.x; - float size = v_data1.y; - float fade_opacity = v_data1[2]; - - float fontScale = u_is_text ? size / 24.0 : size; - - lowp vec4 color = fill_color; - highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale); - lowp float buff = (256.0 - 64.0) / 256.0; - if (u_is_halo) { - color = halo_color; - gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale); - buff = (6.0 - halo_width / fontScale) / SDF_PX; - } - - lowp float dist = texture(u_texture, tex).a; - highp float gamma_scaled = gamma * gamma_scale; - highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - - fragColor = color * (alpha * opacity * fade_opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/symbol_sdf_text.hpp b/include/mbgl/shaders/gl/symbol_sdf_text.hpp deleted file mode 100644 index eecf6ff6b..000000000 --- a/include/mbgl/shaders/gl/symbol_sdf_text.hpp +++ /dev/null @@ -1,261 +0,0 @@ -// Generated code, do not modify this file! -#pragma once -#include - -namespace mbgl { -namespace shaders { - -template <> -struct ShaderSource { - static constexpr const char* name = "SymbolSDFTextProgram"; - static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset; -layout (location = 1) in vec4 a_data; -layout (location = 2) in vec4 a_pixeloffset; -layout (location = 3) in vec3 a_projected_pos; -layout (location = 4) in float a_fade_opacity; - -// contents of a_size vary based on the type of property value -// used for {text,icon}-size. -// For constants, a_size is disabled. -// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature. -// For composite functions: -// [ text-size(lowerZoomStop, feature), -// text-size(upperZoomStop, feature) ] -uniform bool u_is_size_zoom_constant; -uniform bool u_is_size_feature_constant; -uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function -uniform highp float u_size; // used when size is both zoom and feature constant -uniform mat4 u_matrix; -uniform mat4 u_label_plane_matrix; -uniform mat4 u_coord_matrix; -uniform bool u_is_text; -uniform bool u_pitch_with_map; -uniform highp float u_pitch; -uniform bool u_rotate_symbol; -uniform highp float u_aspect_ratio; -uniform highp float u_camera_to_center_distance; -uniform float u_fade_change; -uniform vec2 u_texsize; - -out vec2 v_data0; -out vec3 v_data1; - -#ifndef HAS_UNIFORM_u_fill_color -uniform lowp float u_fill_color_t; -layout (location = 5) in highp vec4 a_fill_color; -out highp vec4 fill_color; -#else -uniform highp vec4 u_fill_color; -#endif -#ifndef HAS_UNIFORM_u_halo_color -uniform lowp float u_halo_color_t; -layout (location = 6) in highp vec4 a_halo_color; -out highp vec4 halo_color; -#else -uniform highp vec4 u_halo_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; -layout (location = 7) in lowp vec2 a_opacity; -out lowp float opacity; -#else -uniform lowp float u_opacity; -#endif -#ifndef HAS_UNIFORM_u_halo_width -uniform lowp float u_halo_width_t; -layout (location = 8) in lowp vec2 a_halo_width; -out lowp float halo_width; -#else -uniform lowp float u_halo_width; -#endif -#ifndef HAS_UNIFORM_u_halo_blur -uniform lowp float u_halo_blur_t; -layout (location = 9) in lowp vec2 a_halo_blur; -out lowp float halo_blur; -#else -uniform lowp float u_halo_blur; -#endif - -void main() { - #ifndef HAS_UNIFORM_u_fill_color -fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); -#else -highp vec4 fill_color = u_fill_color; -#endif - #ifndef HAS_UNIFORM_u_halo_color -halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); -#else -highp vec4 halo_color = u_halo_color; -#endif - #ifndef HAS_UNIFORM_u_opacity -opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else -lowp float opacity = u_opacity; -#endif - #ifndef HAS_UNIFORM_u_halo_width -halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); -#else -lowp float halo_width = u_halo_width; -#endif - #ifndef HAS_UNIFORM_u_halo_blur -halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); -#else -lowp float halo_blur = u_halo_blur; -#endif - - vec2 a_pos = a_pos_offset.xy; - vec2 a_offset = a_pos_offset.zw; - - vec2 a_tex = a_data.xy; - vec2 a_size = a_data.zw; - - float a_size_min = floor(a_size[0] * 0.5); - vec2 a_pxoffset = a_pixeloffset.xy; - - highp float segment_angle = -a_projected_pos[2]; - float size; - - if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = mix(a_size_min, a_size[1], u_size_t) / 128.0; - } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = a_size_min / 128.0; - } else { - size = u_size; - } - - vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1); - highp float camera_to_anchor_distance = projectedPoint.w; - // If the label is pitched with the map, layout is done in pitched space, - // which makes labels in the distance smaller relative to viewport space. - // We counteract part of that effect by multiplying by the perspective ratio. - // If the label isn't pitched with the map, we do layout in viewport space, - // which makes labels in the distance larger relative to the features around - // them. We counteract part of that effect by dividing by the perspective ratio. - 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 = clamp( - 0.5 + 0.5 * distance_ratio, - 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles - 4.0); - - size *= perspective_ratio; - - float fontScale = u_is_text ? size / 24.0 : size; - - highp float symbol_rotation = 0.0; - if (u_rotate_symbol) { - // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units - // To figure out that angle in projected space, we draw a short horizontal line in tile - // space, project it, and measure its angle in projected space. - vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); - - vec2 a = projectedPoint.xy / projectedPoint.w; - vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; - - symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); - } - - highp float angle_sin = sin(segment_angle + symbol_rotation); - highp float angle_cos = cos(segment_angle + symbol_rotation); - mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); - - vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); - gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset), 0.0, 1.0); - float gamma_scale = gl_Position.w; - - vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; - float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); - - v_data0 = a_tex / u_texsize; - v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity); -} -)"; - static constexpr const char* fragment = R"(#define SDF_PX 8.0 - -uniform bool u_is_halo; -uniform sampler2D u_texture; -uniform highp float u_gamma_scale; -uniform lowp float u_device_pixel_ratio; -uniform bool u_is_text; - -in vec2 v_data0; -in vec3 v_data1; - -#ifndef HAS_UNIFORM_u_fill_color -in highp vec4 fill_color; -#else -uniform highp vec4 u_fill_color; -#endif -#ifndef HAS_UNIFORM_u_halo_color -in highp vec4 halo_color; -#else -uniform highp vec4 u_halo_color; -#endif -#ifndef HAS_UNIFORM_u_opacity -in lowp float opacity; -#else -uniform lowp float u_opacity; -#endif -#ifndef HAS_UNIFORM_u_halo_width -in lowp float halo_width; -#else -uniform lowp float u_halo_width; -#endif -#ifndef HAS_UNIFORM_u_halo_blur -in lowp float halo_blur; -#else -uniform lowp float u_halo_blur; -#endif - -void main() { - #ifdef HAS_UNIFORM_u_fill_color -highp vec4 fill_color = u_fill_color; -#endif - #ifdef HAS_UNIFORM_u_halo_color -highp vec4 halo_color = u_halo_color; -#endif - #ifdef HAS_UNIFORM_u_opacity -lowp float opacity = u_opacity; -#endif - #ifdef HAS_UNIFORM_u_halo_width -lowp float halo_width = u_halo_width; -#endif - #ifdef HAS_UNIFORM_u_halo_blur -lowp float halo_blur = u_halo_blur; -#endif - - float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; - - vec2 tex = v_data0.xy; - float gamma_scale = v_data1.x; - float size = v_data1.y; - float fade_opacity = v_data1[2]; - - float fontScale = u_is_text ? size / 24.0 : size; - - lowp vec4 color = fill_color; - highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale); - lowp float buff = (256.0 - 64.0) / 256.0; - if (u_is_halo) { - color = halo_color; - gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale); - buff = (6.0 - halo_width / fontScale) / SDF_PX; - } - - lowp float dist = texture(u_texture, tex).a; - highp float gamma_scaled = gamma * gamma_scale; - highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - - fragColor = color * (alpha * opacity * fade_opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} -)"; -}; - -} // namespace shaders -} // namespace mbgl diff --git a/include/mbgl/shaders/gl/symbol_text_and_icon.hpp b/include/mbgl/shaders/gl/symbol_text_and_icon.hpp index 6cb8f109f..4b55116f1 100644 --- a/include/mbgl/shaders/gl/symbol_text_and_icon.hpp +++ b/include/mbgl/shaders/gl/symbol_text_and_icon.hpp @@ -6,8 +6,8 @@ namespace mbgl { namespace shaders { template <> -struct ShaderSource { - static constexpr const char* name = "SymbolTextAndIconProgram"; +struct ShaderSource { + static constexpr const char* name = "SymbolTextAndIconShader"; static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset; layout (location = 1) in vec4 a_data; layout (location = 2) in vec3 a_projected_pos; @@ -20,63 +20,90 @@ layout (location = 3) in float a_fade_opacity; // For composite functions: // [ text-size(lowerZoomStop, feature), // text-size(upperZoomStop, feature) ] -uniform bool u_is_size_zoom_constant; -uniform bool u_is_size_feature_constant; -uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function -uniform highp float u_size; // used when size is both zoom and feature constant -uniform mat4 u_matrix; -uniform mat4 u_label_plane_matrix; -uniform mat4 u_coord_matrix; -uniform bool u_is_text; -uniform bool u_pitch_with_map; -uniform highp float u_pitch; -uniform bool u_rotate_symbol; -uniform highp float u_aspect_ratio; -uniform highp float u_camera_to_center_distance; -uniform float u_fade_change; -uniform vec2 u_texsize; -uniform vec2 u_texsize_icon; + +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform SymbolDrawableUBO { + highp mat4 u_matrix; + highp mat4 u_label_plane_matrix; + highp mat4 u_coord_matrix; + + highp vec2 u_texsize; + highp vec2 u_texsize_icon; + + bool u_is_text_prop; + bool u_rotate_symbol; + bool u_pitch_with_map; + bool u_is_size_zoom_constant; + bool u_is_size_feature_constant; + + highp float u_size_t; // used to interpolate between zoom stops when size is a composite function + highp float u_size; // used when size is both zoom and feature constant + + // Interpolations + highp float u_fill_color_t; + highp float u_halo_color_t; + highp float u_opacity_t; + highp float u_halo_width_t; + highp float u_halo_blur_t; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; out vec4 v_data0; out vec4 v_data1; #ifndef HAS_UNIFORM_u_fill_color -uniform lowp float u_fill_color_t; layout (location = 4) in highp vec4 a_fill_color; out highp vec4 fill_color; -#else -uniform highp vec4 u_fill_color; #endif #ifndef HAS_UNIFORM_u_halo_color -uniform lowp float u_halo_color_t; layout (location = 5) in highp vec4 a_halo_color; out highp vec4 halo_color; -#else -uniform highp vec4 u_halo_color; #endif #ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; layout (location = 6) in lowp vec2 a_opacity; out lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_halo_width -uniform lowp float u_halo_width_t; layout (location = 7) in lowp vec2 a_halo_width; out lowp float halo_width; -#else -uniform lowp float u_halo_width; #endif #ifndef HAS_UNIFORM_u_halo_blur -uniform lowp float u_halo_blur_t; layout (location = 8) in lowp vec2 a_halo_blur; out lowp float halo_blur; -#else -uniform lowp float u_halo_blur; #endif void main() { + highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color; + highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color; + highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; + highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width; + highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur; + #ifndef HAS_UNIFORM_u_fill_color fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); #else @@ -165,7 +192,7 @@ lowp float halo_blur = u_halo_blur; float gamma_scale = gl_Position.w; vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); v_data0.xy = a_tex / u_texsize; @@ -178,42 +205,57 @@ lowp float halo_blur = u_halo_blur; #define SDF 1.0 #define ICON 0.0 -uniform bool u_is_halo; +layout (std140) uniform SymbolTilePropsUBO { + bool u_is_text; + bool u_is_halo; + highp float u_gamma_scale; + lowp float tileprops_pad1; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; + uniform sampler2D u_texture; uniform sampler2D u_texture_icon; -uniform highp float u_gamma_scale; -uniform lowp float u_device_pixel_ratio; in vec4 v_data0; in vec4 v_data1; #ifndef HAS_UNIFORM_u_fill_color in highp vec4 fill_color; -#else -uniform highp vec4 u_fill_color; #endif #ifndef HAS_UNIFORM_u_halo_color in highp vec4 halo_color; -#else -uniform highp vec4 u_halo_color; #endif #ifndef HAS_UNIFORM_u_opacity in lowp float opacity; -#else -uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_halo_width in lowp float halo_width; -#else -uniform lowp float u_halo_width; #endif #ifndef HAS_UNIFORM_u_halo_blur in lowp float halo_blur; -#else -uniform lowp float u_halo_blur; #endif void main() { + highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color; + highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color; + highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; + highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width; + highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur; + #ifdef HAS_UNIFORM_u_fill_color highp vec4 fill_color = u_fill_color; #endif @@ -245,7 +287,7 @@ lowp float halo_blur = u_halo_blur; vec2 tex = v_data0.xy; - float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; + float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO; float gamma_scale = v_data1.x; float size = v_data1.y; diff --git a/include/mbgl/shaders/gl/drawable_wide_vector.hpp b/include/mbgl/shaders/gl/wide_vector.hpp similarity index 100% rename from include/mbgl/shaders/gl/drawable_wide_vector.hpp rename to include/mbgl/shaders/gl/wide_vector.hpp diff --git a/include/mbgl/shaders/shader_manifest.hpp b/include/mbgl/shaders/shader_manifest.hpp index 1f537fae2..3ff0c8042 100644 --- a/include/mbgl/shaders/shader_manifest.hpp +++ b/include/mbgl/shaders/shader_manifest.hpp @@ -3,61 +3,36 @@ #include #if MLN_RENDER_BACKEND_OPENGL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include #include #include -#include #include #include +#include +#include #include -#include -#include -#include +#include #include #include -#include -#include +#include +#include +#include +#include #include +#include #include #include +#include #include #include +#include +#include #include -#include #include #include -#include -#include +#include #include +#include #endif diff --git a/include/mbgl/shaders/shader_source.hpp b/include/mbgl/shaders/shader_source.hpp index 4ae34388e..5e387d186 100644 --- a/include/mbgl/shaders/shader_source.hpp +++ b/include/mbgl/shaders/shader_source.hpp @@ -9,6 +9,8 @@ namespace shaders { /// source code for the desired program and graphics back-end. enum class BuiltIn { None, + Prelude, + ClippingMaskProgram, BackgroundShader, BackgroundPatternShader, CircleShader, @@ -38,34 +40,7 @@ enum class BuiltIn { SymbolIconShader, SymbolSDFIconShader, SymbolTextAndIconShader, - WideVectorShader, - Prelude, - BackgroundProgram, - BackgroundPatternProgram, - CircleProgram, - ClippingMaskProgram, - CollisionBoxProgram, - CollisionCircleProgram, - DebugProgram, - FillExtrusionPatternProgram, - FillExtrusionProgram, - FillOutlinePatternProgram, - FillOutlineProgram, - FillPatternProgram, - FillProgram, - HeatmapTextureProgram, - HeatmapProgram, - HillshadePrepareProgram, - HillshadeProgram, - LineGradientProgram, - LinePatternProgram, - LineSDFProgram, - LineProgram, - RasterProgram, - SymbolIconProgram, - SymbolSDFTextProgram, - SymbolSDFIconProgram, - SymbolTextAndIconProgram + WideVectorShader }; /// @brief Select shader source based on a program type and a desired diff --git a/shaders/background.fragment.glsl b/shaders/background.fragment.glsl index fdb7205e2..2b55c4991 100644 --- a/shaders/background.fragment.glsl +++ b/shaders/background.fragment.glsl @@ -1,9 +1,13 @@ -uniform vec4 u_color; -uniform float u_opacity; +layout (std140) uniform BackgroundPropsUBO { + highp vec4 u_color; + highp float u_opacity; + lowp float props_pad1; + lowp float props_pad2; + lowp float props_pad3; +}; void main() { fragColor = u_color * u_opacity; - #ifdef OVERDRAW_INSPECTOR fragColor = vec4(1.0); #endif diff --git a/shaders/background.vertex.glsl b/shaders/background.vertex.glsl index 3b0ec957f..5e4c0dd3d 100644 --- a/shaders/background.vertex.glsl +++ b/shaders/background.vertex.glsl @@ -1,5 +1,7 @@ layout (location = 0) in vec2 a_pos; -uniform mat4 u_matrix; +layout (std140) uniform BackgroundDrawableUBO { + highp mat4 u_matrix; +}; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); diff --git a/shaders/background_pattern.fragment.glsl b/shaders/background_pattern.fragment.glsl index 7cbb25d9c..8729d5d62 100644 --- a/shaders/background_pattern.fragment.glsl +++ b/shaders/background_pattern.fragment.glsl @@ -1,23 +1,40 @@ -uniform vec2 u_pattern_tl_a; -uniform vec2 u_pattern_br_a; -uniform vec2 u_pattern_tl_b; -uniform vec2 u_pattern_br_b; -uniform vec2 u_texsize; -uniform float u_mix; -uniform float u_opacity; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform BackgroundPatternPropsUBO { + highp vec2 u_pattern_tl_a; + highp vec2 u_pattern_br_a; + highp vec2 u_pattern_tl_b; + highp vec2 u_pattern_br_b; + highp vec2 u_pattern_size_a; + highp vec2 u_pattern_size_b; + highp float u_scale_a; + highp float u_scale_b; + highp float u_mix; + highp float u_opacity; +}; uniform sampler2D u_image; -in vec2 v_pos_a; -in vec2 v_pos_b; +in mediump vec2 v_pos_a; +in mediump vec2 v_pos_b; void main() { vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord); + vec2 pos = mix(u_pattern_tl_a / u_pattern_atlas_texsize, u_pattern_br_a / u_pattern_atlas_texsize, imagecoord); vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b); + vec2 pos2 = mix(u_pattern_tl_b / u_pattern_atlas_texsize, u_pattern_br_b / u_pattern_atlas_texsize, imagecoord_b); vec4 color2 = texture(u_image, pos2); fragColor = mix(color1, color2, u_mix) * u_opacity; diff --git a/shaders/background_pattern.vertex.glsl b/shaders/background_pattern.vertex.glsl index ddada5e6c..1341c0651 100644 --- a/shaders/background_pattern.vertex.glsl +++ b/shaders/background_pattern.vertex.glsl @@ -1,15 +1,29 @@ -uniform mat4 u_matrix; -uniform vec2 u_pattern_size_a; -uniform vec2 u_pattern_size_b; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform float u_scale_a; -uniform float u_scale_b; -uniform float u_tile_units_to_pixels; +layout (std140) uniform BackgroundPatternDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_tile_units_to_pixels; + lowp float drawable_pad1; + lowp float drawable_pad2; + lowp float drawable_pad3; +}; + +layout (std140) uniform BackgroundPatternPropsUBO { + highp vec2 u_pattern_tl_a; + highp vec2 u_pattern_br_a; + highp vec2 u_pattern_tl_b; + highp vec2 u_pattern_br_b; + highp vec2 u_pattern_size_a; + highp vec2 u_pattern_size_b; + highp float u_scale_a; + highp float u_scale_b; + highp float u_mix; + highp float u_opacity; +}; layout (location = 0) in vec2 a_pos; -out vec2 v_pos_a; -out vec2 v_pos_b; +out mediump vec2 v_pos_a; +out mediump vec2 v_pos_b; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); diff --git a/shaders/circle.fragment.glsl b/shaders/circle.fragment.glsl index 9aa802565..afb58420e 100644 --- a/shaders/circle.fragment.glsl +++ b/shaders/circle.fragment.glsl @@ -1,5 +1,18 @@ in vec3 v_data; +layout (std140) uniform CircleEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_stroke_color; + mediump float u_radius; + lowp float u_blur; + lowp float u_opacity; + mediump float u_stroke_width; + lowp float u_stroke_opacity; + bool u_scale_with_map; + bool u_pitch_with_map; + lowp float props_pad1; +}; + #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur diff --git a/shaders/circle.vertex.glsl b/shaders/circle.vertex.glsl index 96cca8760..a6c16eea5 100644 --- a/shaders/circle.vertex.glsl +++ b/shaders/circle.vertex.glsl @@ -1,13 +1,47 @@ -uniform mat4 u_matrix; -uniform bool u_scale_with_map; -uniform bool u_pitch_with_map; -uniform vec2 u_extrude_scale; -uniform lowp float u_device_pixel_ratio; -uniform highp float u_camera_to_center_distance; - layout (location = 0) in vec2 a_pos; out vec3 v_data; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CircleDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_extrude_scale; + // Interpolations + lowp float u_color_t; + lowp float u_radius_t; + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_stroke_color_t; + lowp float u_stroke_width_t; + lowp float u_stroke_opacity_t; + lowp float drawable_pad1; + lowp float drawable_pad2; + lowp float drawable_pad3; +}; + +layout (std140) uniform CircleEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_stroke_color; + mediump float u_radius; + lowp float u_blur; + lowp float u_opacity; + mediump float u_stroke_width; + lowp float u_stroke_opacity; + bool u_scale_with_map; + bool u_pitch_with_map; + lowp float props_pad1; +}; + #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur @@ -57,7 +91,7 @@ void main(void) { // This is a minimum blur distance that serves as a faux-antialiasing for // the circle. since blur is a ratio of the circle's size and the intent is // to keep the blur at roughly 1px, the two are inversely related. - lowp float antialiasblur = 1.0 / u_device_pixel_ratio / (radius + stroke_width); + lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width); v_data = vec3(extrude.x, extrude.y, antialiasblur); } diff --git a/shaders/collision_box.fragment.glsl b/shaders/collision_box.fragment.glsl index 7132879bd..7fe3151dc 100644 --- a/shaders/collision_box.fragment.glsl +++ b/shaders/collision_box.fragment.glsl @@ -1,4 +1,3 @@ - in float v_placed; in float v_notUsed; diff --git a/shaders/collision_box.vertex.glsl b/shaders/collision_box.vertex.glsl index f5bd79acb..eca7f9568 100644 --- a/shaders/collision_box.vertex.glsl +++ b/shaders/collision_box.vertex.glsl @@ -4,9 +4,27 @@ layout (location = 2) in vec2 a_extrude; layout (location = 3) in vec2 a_placed; layout (location = 4) in vec2 a_shift; -uniform mat4 u_matrix; -uniform vec2 u_extrude_scale; -uniform float u_camera_to_center_distance; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CollisionDrawableUBO { + highp mat4 u_matrix; +}; + +layout (std140) uniform CollisionTilePropsUBO { + highp vec2 u_extrude_scale; + highp float u_overscale_factor; + lowp float drawable_pad1; +}; out float v_placed; out float v_notUsed; diff --git a/shaders/collision_circle.fragment.glsl b/shaders/collision_circle.fragment.glsl index 9623672ae..611cf6b9c 100644 --- a/shaders/collision_circle.fragment.glsl +++ b/shaders/collision_circle.fragment.glsl @@ -1,4 +1,20 @@ -uniform float u_overscale_factor; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CollisionTilePropsUBO { + highp vec2 u_extrude_scale; + highp float u_overscale_factor; + lowp float drawable_pad1; +}; in float v_placed; in float v_notUsed; diff --git a/shaders/collision_circle.vertex.glsl b/shaders/collision_circle.vertex.glsl index 2d61e47c9..2cc20f008 100644 --- a/shaders/collision_circle.vertex.glsl +++ b/shaders/collision_circle.vertex.glsl @@ -3,9 +3,27 @@ layout (location = 1) in vec2 a_anchor_pos; layout (location = 2) in vec2 a_extrude; layout (location = 3) in vec2 a_placed; -uniform mat4 u_matrix; -uniform vec2 u_extrude_scale; -uniform float u_camera_to_center_distance; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform CollisionDrawableUBO { + highp mat4 u_matrix; +}; + +layout (std140) uniform CollisionTilePropsUBO { + highp vec2 u_extrude_scale; + highp float u_overscale_factor; + lowp float drawable_pad1; +}; out float v_placed; out float v_notUsed; diff --git a/shaders/drawable.custom.symbol_icon.fragment.glsl b/shaders/custom.symbol_icon.fragment.glsl similarity index 100% rename from shaders/drawable.custom.symbol_icon.fragment.glsl rename to shaders/custom.symbol_icon.fragment.glsl diff --git a/shaders/drawable.custom.symbol_icon.vertex.glsl b/shaders/custom.symbol_icon.vertex.glsl similarity index 100% rename from shaders/drawable.custom.symbol_icon.vertex.glsl rename to shaders/custom.symbol_icon.vertex.glsl diff --git a/shaders/drawable.custom_geometry.fragment.glsl b/shaders/custom_geometry.fragment.glsl similarity index 100% rename from shaders/drawable.custom_geometry.fragment.glsl rename to shaders/custom_geometry.fragment.glsl diff --git a/shaders/drawable.custom_geometry.vertex.glsl b/shaders/custom_geometry.vertex.glsl similarity index 100% rename from shaders/drawable.custom_geometry.vertex.glsl rename to shaders/custom_geometry.vertex.glsl diff --git a/shaders/debug.fragment.glsl b/shaders/debug.fragment.glsl index 53e0f40d7..2376634a8 100644 --- a/shaders/debug.fragment.glsl +++ b/shaders/debug.fragment.glsl @@ -1,4 +1,12 @@ -uniform highp vec4 u_color; +layout (std140) uniform DebugUBO { + highp mat4 u_matrix; + highp vec4 u_color; + highp float u_overlay_scale; + lowp float pad1; + lowp float pad2; + lowp float pad3; +}; + uniform sampler2D u_overlay; in vec2 v_uv; diff --git a/shaders/debug.vertex.glsl b/shaders/debug.vertex.glsl index f459ffe41..10236b141 100644 --- a/shaders/debug.vertex.glsl +++ b/shaders/debug.vertex.glsl @@ -1,8 +1,14 @@ layout (location = 0) in vec2 a_pos; out vec2 v_uv; -uniform mat4 u_matrix; -uniform float u_overlay_scale; +layout (std140) uniform DebugUBO { + highp mat4 u_matrix; + highp vec4 u_color; + highp float u_overlay_scale; + lowp float pad1; + lowp float pad2; + lowp float pad3; +}; void main() { // This vertex shader expects a EXTENT x EXTENT quad, diff --git a/shaders/drawable.background.fragment.glsl b/shaders/drawable.background.fragment.glsl deleted file mode 100644 index 2b55c4991..000000000 --- a/shaders/drawable.background.fragment.glsl +++ /dev/null @@ -1,14 +0,0 @@ -layout (std140) uniform BackgroundPropsUBO { - highp vec4 u_color; - highp float u_opacity; - lowp float props_pad1; - lowp float props_pad2; - lowp float props_pad3; -}; - -void main() { - fragColor = u_color * u_opacity; -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.background.vertex.glsl b/shaders/drawable.background.vertex.glsl deleted file mode 100644 index 5e4c0dd3d..000000000 --- a/shaders/drawable.background.vertex.glsl +++ /dev/null @@ -1,8 +0,0 @@ -layout (location = 0) in vec2 a_pos; -layout (std140) uniform BackgroundDrawableUBO { - highp mat4 u_matrix; -}; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} diff --git a/shaders/drawable.background_pattern.fragment.glsl b/shaders/drawable.background_pattern.fragment.glsl deleted file mode 100644 index 8729d5d62..000000000 --- a/shaders/drawable.background_pattern.fragment.glsl +++ /dev/null @@ -1,45 +0,0 @@ -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform BackgroundPatternPropsUBO { - highp vec2 u_pattern_tl_a; - highp vec2 u_pattern_br_a; - highp vec2 u_pattern_tl_b; - highp vec2 u_pattern_br_b; - highp vec2 u_pattern_size_a; - highp vec2 u_pattern_size_b; - highp float u_scale_a; - highp float u_scale_b; - highp float u_mix; - highp float u_opacity; -}; - -uniform sampler2D u_image; - -in mediump vec2 v_pos_a; -in mediump vec2 v_pos_b; - -void main() { - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(u_pattern_tl_a / u_pattern_atlas_texsize, u_pattern_br_a / u_pattern_atlas_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(u_pattern_tl_b / u_pattern_atlas_texsize, u_pattern_br_b / u_pattern_atlas_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - fragColor = mix(color1, color2, u_mix) * u_opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.background_pattern.vertex.glsl b/shaders/drawable.background_pattern.vertex.glsl deleted file mode 100644 index 1341c0651..000000000 --- a/shaders/drawable.background_pattern.vertex.glsl +++ /dev/null @@ -1,33 +0,0 @@ -layout (std140) uniform BackgroundPatternDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_tile_units_to_pixels; - lowp float drawable_pad1; - lowp float drawable_pad2; - lowp float drawable_pad3; -}; - -layout (std140) uniform BackgroundPatternPropsUBO { - highp vec2 u_pattern_tl_a; - highp vec2 u_pattern_br_a; - highp vec2 u_pattern_tl_b; - highp vec2 u_pattern_br_b; - highp vec2 u_pattern_size_a; - highp vec2 u_pattern_size_b; - highp float u_scale_a; - highp float u_scale_b; - highp float u_mix; - highp float u_opacity; -}; - -layout (location = 0) in vec2 a_pos; -out mediump vec2 v_pos_a; -out mediump vec2 v_pos_b; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos); -} diff --git a/shaders/drawable.circle.fragment.glsl b/shaders/drawable.circle.fragment.glsl deleted file mode 100644 index afb58420e..000000000 --- a/shaders/drawable.circle.fragment.glsl +++ /dev/null @@ -1,52 +0,0 @@ -in vec3 v_data; - -layout (std140) uniform CircleEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_stroke_color; - mediump float u_radius; - lowp float u_blur; - lowp float u_opacity; - mediump float u_stroke_width; - lowp float u_stroke_opacity; - bool u_scale_with_map; - bool u_pitch_with_map; - lowp float props_pad1; -}; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define mediump float radius -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity -#pragma mapbox: define highp vec4 stroke_color -#pragma mapbox: define mediump float stroke_width -#pragma mapbox: define lowp float stroke_opacity - -void main() { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize mediump float radius - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize highp vec4 stroke_color - #pragma mapbox: initialize mediump float stroke_width - #pragma mapbox: initialize lowp float stroke_opacity - - vec2 extrude = v_data.xy; - float extrude_length = length(extrude); - - lowp float antialiasblur = v_data.z; - float antialiased_blur = -max(blur, antialiasblur); - - float opacity_t = smoothstep(0.0, antialiased_blur, extrude_length - 1.0); - - float color_t = stroke_width < 0.01 ? 0.0 : smoothstep( - antialiased_blur, - 0.0, - extrude_length - radius / (radius + stroke_width) - ); - - fragColor = opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.circle.vertex.glsl b/shaders/drawable.circle.vertex.glsl deleted file mode 100644 index a6c16eea5..000000000 --- a/shaders/drawable.circle.vertex.glsl +++ /dev/null @@ -1,97 +0,0 @@ -layout (location = 0) in vec2 a_pos; -out vec3 v_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CircleDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_extrude_scale; - // Interpolations - lowp float u_color_t; - lowp float u_radius_t; - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_stroke_color_t; - lowp float u_stroke_width_t; - lowp float u_stroke_opacity_t; - lowp float drawable_pad1; - lowp float drawable_pad2; - lowp float drawable_pad3; -}; - -layout (std140) uniform CircleEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_stroke_color; - mediump float u_radius; - lowp float u_blur; - lowp float u_opacity; - mediump float u_stroke_width; - lowp float u_stroke_opacity; - bool u_scale_with_map; - bool u_pitch_with_map; - lowp float props_pad1; -}; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define mediump float radius -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity -#pragma mapbox: define highp vec4 stroke_color -#pragma mapbox: define mediump float stroke_width -#pragma mapbox: define lowp float stroke_opacity - -void main(void) { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize mediump float radius - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize highp vec4 stroke_color - #pragma mapbox: initialize mediump float stroke_width - #pragma mapbox: initialize lowp float stroke_opacity - - // unencode the extrusion vector that we snuck into the a_pos vector - vec2 extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); - - // multiply a_pos by 0.5, since we had it * 2 in order to sneak - // in extrusion data - vec2 circle_center = floor(a_pos * 0.5); - if (u_pitch_with_map) { - vec2 corner_position = circle_center; - if (u_scale_with_map) { - corner_position += extrude * (radius + stroke_width) * u_extrude_scale; - } else { - // Pitching the circle with the map effectively scales it with the map - // To counteract the effect for pitch-scale: viewport, we rescale the - // whole circle based on the pitch scaling effect at its central point - vec4 projected_center = u_matrix * vec4(circle_center, 0, 1); - corner_position += extrude * (radius + stroke_width) * u_extrude_scale * (projected_center.w / u_camera_to_center_distance); - } - - gl_Position = u_matrix * vec4(corner_position, 0, 1); - } else { - gl_Position = u_matrix * vec4(circle_center, 0, 1); - - if (u_scale_with_map) { - gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * u_camera_to_center_distance; - } else { - gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * gl_Position.w; - } - } - - // This is a minimum blur distance that serves as a faux-antialiasing for - // the circle. since blur is a ratio of the circle's size and the intent is - // to keep the blur at roughly 1px, the two are inversely related. - lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width); - - v_data = vec3(extrude.x, extrude.y, antialiasblur); -} diff --git a/shaders/drawable.collision_box.fragment.glsl b/shaders/drawable.collision_box.fragment.glsl deleted file mode 100644 index 7fe3151dc..000000000 --- a/shaders/drawable.collision_box.fragment.glsl +++ /dev/null @@ -1,20 +0,0 @@ -in float v_placed; -in float v_notUsed; - -void main() { - - float alpha = 0.5; - - // Red = collision, hide label - fragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha; - - // Blue = no collision, label is showing - if (v_placed > 0.5) { - fragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha; - } - - if (v_notUsed > 0.5) { - // This box not used, fade it out - fragColor *= .1; - } -} diff --git a/shaders/drawable.collision_box.vertex.glsl b/shaders/drawable.collision_box.vertex.glsl deleted file mode 100644 index eca7f9568..000000000 --- a/shaders/drawable.collision_box.vertex.glsl +++ /dev/null @@ -1,45 +0,0 @@ -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_anchor_pos; -layout (location = 2) in vec2 a_extrude; -layout (location = 3) in vec2 a_placed; -layout (location = 4) in vec2 a_shift; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CollisionDrawableUBO { - highp mat4 u_matrix; -}; - -layout (std140) uniform CollisionTilePropsUBO { - highp vec2 u_extrude_scale; - highp float u_overscale_factor; - lowp float drawable_pad1; -}; - -out float v_placed; -out 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 = 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 + a_shift) * u_extrude_scale * gl_Position.w * collision_perspective_ratio; - - v_placed = a_placed.x; - v_notUsed = a_placed.y; -} diff --git a/shaders/drawable.collision_circle.fragment.glsl b/shaders/drawable.collision_circle.fragment.glsl deleted file mode 100644 index 611cf6b9c..000000000 --- a/shaders/drawable.collision_circle.fragment.glsl +++ /dev/null @@ -1,50 +0,0 @@ -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CollisionTilePropsUBO { - highp vec2 u_extrude_scale; - highp float u_overscale_factor; - lowp float drawable_pad1; -}; - -in float v_placed; -in float v_notUsed; -in float v_radius; -in highp vec2 v_extrude; -in vec2 v_extrude_scale; - -void main() { - float alpha = 0.5; - - // Red = collision, hide label - vec4 color = vec4(1.0, 0.0, 0.0, 1.0) * alpha; - - // Blue = no collision, label is showing - if (v_placed > 0.5) { - color = vec4(0.0, 0.0, 1.0, 0.5) * alpha; - } - - if (v_notUsed > 0.5) { - // This box not used, fade it out - color *= .2; - } - - float extrude_scale_length = length(v_extrude_scale); - float extrude_length = length(v_extrude) * extrude_scale_length; - float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor; - float radius = v_radius * extrude_scale_length; - - float distance_to_edge = abs(extrude_length - radius); - float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge); - - fragColor = opacity_t * color; -} diff --git a/shaders/drawable.collision_circle.vertex.glsl b/shaders/drawable.collision_circle.vertex.glsl deleted file mode 100644 index 2cc20f008..000000000 --- a/shaders/drawable.collision_circle.vertex.glsl +++ /dev/null @@ -1,53 +0,0 @@ -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_anchor_pos; -layout (location = 2) in vec2 a_extrude; -layout (location = 3) in vec2 a_placed; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform CollisionDrawableUBO { - highp mat4 u_matrix; -}; - -layout (std140) uniform CollisionTilePropsUBO { - highp vec2 u_extrude_scale; - highp float u_overscale_factor; - lowp float drawable_pad1; -}; - -out float v_placed; -out float v_notUsed; -out float v_radius; -out highp vec2 v_extrude; -out vec2 v_extrude_scale; - -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 = clamp( - 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance), - 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles - 4.0); - - gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0); - - highp float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur - gl_Position.xy += a_extrude * u_extrude_scale * padding_factor * gl_Position.w * collision_perspective_ratio; - - v_placed = a_placed.x; - v_notUsed = a_placed.y; - v_radius = abs(a_extrude.y); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius - - v_extrude = a_extrude * padding_factor; - v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio; -} diff --git a/shaders/drawable.debug.fragment.glsl b/shaders/drawable.debug.fragment.glsl deleted file mode 100644 index 2376634a8..000000000 --- a/shaders/drawable.debug.fragment.glsl +++ /dev/null @@ -1,17 +0,0 @@ -layout (std140) uniform DebugUBO { - highp mat4 u_matrix; - highp vec4 u_color; - highp float u_overlay_scale; - lowp float pad1; - lowp float pad2; - lowp float pad3; -}; - -uniform sampler2D u_overlay; - -in vec2 v_uv; - -void main() { - vec4 overlay_color = texture(u_overlay, v_uv); - fragColor = mix(u_color, overlay_color, overlay_color.a); -} diff --git a/shaders/drawable.debug.vertex.glsl b/shaders/drawable.debug.vertex.glsl deleted file mode 100644 index 10236b141..000000000 --- a/shaders/drawable.debug.vertex.glsl +++ /dev/null @@ -1,18 +0,0 @@ -layout (location = 0) in vec2 a_pos; -out vec2 v_uv; - -layout (std140) uniform DebugUBO { - highp mat4 u_matrix; - highp vec4 u_color; - highp float u_overlay_scale; - lowp float pad1; - lowp float pad2; - lowp float pad3; -}; - -void main() { - // This vertex shader expects a EXTENT x EXTENT quad, - // The UV co-ordinates for the overlay texture can be calculated using that knowledge - v_uv = a_pos / 8192.0; - gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, 0, 1); -} diff --git a/shaders/drawable.fill.fragment.glsl b/shaders/drawable.fill.fragment.glsl deleted file mode 100644 index cd2d2aa4a..000000000 --- a/shaders/drawable.fill.fragment.glsl +++ /dev/null @@ -1,22 +0,0 @@ -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define lowp float opacity - -void main() { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize lowp float opacity - - fragColor = color * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.fill.vertex.glsl b/shaders/drawable.fill.vertex.glsl deleted file mode 100644 index f77883221..000000000 --- a/shaders/drawable.fill.vertex.glsl +++ /dev/null @@ -1,29 +0,0 @@ -layout (std140) uniform FillDrawableUBO { - highp mat4 u_matrix; - // Interpolations - highp float u_color_t; - highp float u_opacity_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define lowp float opacity - -void main() { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize lowp float opacity - - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} diff --git a/shaders/drawable.fill_extrusion.fragment.glsl b/shaders/drawable.fill_extrusion.fragment.glsl deleted file mode 100644 index c7913c30e..000000000 --- a/shaders/drawable.fill_extrusion.fragment.glsl +++ /dev/null @@ -1,9 +0,0 @@ -in vec4 v_color; - -void main() { - fragColor = v_color; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.fill_extrusion.vertex.glsl b/shaders/drawable.fill_extrusion.vertex.glsl deleted file mode 100644 index ae4dc60fd..000000000 --- a/shaders/drawable.fill_extrusion.vertex.glsl +++ /dev/null @@ -1,96 +0,0 @@ -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec4 a_normal_ed; -out vec4 v_color; - -layout (std140) uniform FillExtrusionDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_height_factor; - highp float u_tile_ratio; - // Interpolations - highp float u_base_t; - highp float u_height_t; - highp float u_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform FillExtrusionTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillExtrusionPropsUBO { - highp vec4 u_color; - highp vec3 u_lightcolor; - lowp float props_pad1; - highp vec3 u_lightpos; - highp float u_base; - highp float u_height; - highp float u_lightintensity; - highp float u_vertical_gradient; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; - lowp float props_pad2; -}; - -#pragma mapbox: define highp float base -#pragma mapbox: define highp float height -#pragma mapbox: define highp vec4 color - -void main() { - #pragma mapbox: initialize highp float base - #pragma mapbox: initialize highp float height - #pragma mapbox: initialize highp vec4 color - - vec3 normal = a_normal_ed.xyz; - - base = max(0.0, base); - height = max(0.0, height); - - float t = mod(normal.x, 2.0); - - gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1); - - // Relative luminance (how dark/bright is the surface color?) - float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722; - - v_color = vec4(0.0, 0.0, 0.0, 1.0); - - // Add slight ambient lighting so no extrusions are totally black - vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0); - color += ambientlight; - - // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray - float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0); - - // Adjust directional so that - // the range of values for highlight/shading is narrower - // with lower light intensity - // and with lighter/brighter surface colors - directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional); - - // Add gradient along z axis of side surfaces - if (normal.y != 0.0) { - // This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient, - // and otherwise calculates the gradient based on base + height - directional *= ( - (1.0 - u_vertical_gradient) + - (u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0))); - } - - // Assign final color based on surface + ambient light color, diffuse light directional, and light color - // with lower bounds adjusted to hue of light - // so that shading is tinted with the complementary (opposite) color to the light color - v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0); - v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0); - v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0); - v_color *= u_opacity; -} diff --git a/shaders/drawable.fill_extrusion_pattern.fragment.glsl b/shaders/drawable.fill_extrusion_pattern.fragment.glsl deleted file mode 100644 index a4ce886e3..000000000 --- a/shaders/drawable.fill_extrusion_pattern.fragment.glsl +++ /dev/null @@ -1,62 +0,0 @@ -in vec2 v_pos_a; -in vec2 v_pos_b; -in vec4 v_lighting; - -layout (std140) uniform FillExtrusionTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillExtrusionPropsUBO { - highp vec4 u_color; - highp vec3 u_lightcolor; - lowp float props_pad1; - highp vec3 u_lightpos; - highp float u_base; - highp float u_height; - highp float u_lightintensity; - highp float u_vertical_gradient; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -#pragma mapbox: define lowp float base -#pragma mapbox: define lowp float height -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to - -void main() { - #pragma mapbox: initialize lowp float base - #pragma mapbox: initialize lowp float height - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - vec4 mixedColor = mix(color1, color2, u_fade); - - fragColor = mixedColor * v_lighting; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.fill_extrusion_pattern.vertex.glsl b/shaders/drawable.fill_extrusion_pattern.vertex.glsl deleted file mode 100644 index 71645f7f3..000000000 --- a/shaders/drawable.fill_extrusion_pattern.vertex.glsl +++ /dev/null @@ -1,115 +0,0 @@ -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec4 a_normal_ed; - -out vec2 v_pos_a; -out vec2 v_pos_b; -out vec4 v_lighting; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillExtrusionDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_height_factor; - highp float u_tile_ratio; - // Interpolations - highp float u_base_t; - highp float u_height_t; - highp float u_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform FillExtrusionTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillExtrusionPropsUBO { - highp vec4 u_color; - highp vec3 u_lightcolor; - lowp float props_pad1; - highp vec3 u_lightpos; - highp float u_base; - highp float u_height; - highp float u_lightintensity; - highp float u_vertical_gradient; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; - lowp float props_pad2; -}; - -#pragma mapbox: define lowp float base -#pragma mapbox: define lowp float height -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to - -void main() { - #pragma mapbox: initialize lowp float base - #pragma mapbox: initialize lowp float height - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_pixel_ratio; - float tileRatio = u_tile_ratio; - float fromScale = u_from_scale; - float toScale = u_to_scale; - - vec3 normal = a_normal_ed.xyz; - float edgedistance = a_normal_ed.w; - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - - base = max(0.0, base); - height = max(0.0, height); - - float t = mod(normal.x, 2.0); - float z = t > 0.0 ? height : base; - - gl_Position = u_matrix * vec4(a_pos, z, 1); - - vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0 - ? a_pos // extrusion top - : vec2(edgedistance, z * u_height_factor); // extrusion side - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, pos); - - v_lighting = vec4(0.0, 0.0, 0.0, 1.0); - float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0); - directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional); - - if (normal.y != 0.0) { - // This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient, - // and otherwise calculates the gradient based on base + height - directional *= ( - (1.0 - u_vertical_gradient) + - (u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0))); - } - - v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0)); - v_lighting *= u_opacity; -} diff --git a/shaders/drawable.fill_outline.fragment.glsl b/shaders/drawable.fill_outline.fragment.glsl deleted file mode 100644 index eacab7664..000000000 --- a/shaders/drawable.fill_outline.fragment.glsl +++ /dev/null @@ -1,26 +0,0 @@ -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -in vec2 v_pos; - -#pragma mapbox: define highp vec4 outline_color -#pragma mapbox: define lowp float opacity - -void main() { - #pragma mapbox: initialize highp vec4 outline_color - #pragma mapbox: initialize lowp float opacity - - float dist = length(v_pos - gl_FragCoord.xy); - float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - fragColor = outline_color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.fill_outline.vertex.glsl b/shaders/drawable.fill_outline.vertex.glsl deleted file mode 100644 index 50dadb4c3..000000000 --- a/shaders/drawable.fill_outline.vertex.glsl +++ /dev/null @@ -1,44 +0,0 @@ -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillOutlineDrawableUBO { - highp mat4 u_matrix; - // Interpolations - highp float u_outline_color_t; - highp float u_opacity_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -out vec2 v_pos; - -#pragma mapbox: define highp vec4 outline_color -#pragma mapbox: define lowp float opacity - -void main() { - #pragma mapbox: initialize highp vec4 outline_color - #pragma mapbox: initialize lowp float opacity - - gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; -} diff --git a/shaders/drawable.fill_outline_pattern.fragment.glsl b/shaders/drawable.fill_outline_pattern.fragment.glsl deleted file mode 100644 index 7e6175401..000000000 --- a/shaders/drawable.fill_outline_pattern.fragment.glsl +++ /dev/null @@ -1,57 +0,0 @@ -layout (std140) uniform FillOutlinePatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -uniform sampler2D u_image; - -in vec2 v_pos_a; -in vec2 v_pos_b; -in vec2 v_pos; - -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp vec4 pattern_from -#pragma mapbox: define lowp vec4 pattern_to - -void main() { - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - // find distance to outline for alpha interpolation - - float dist = length(v_pos - gl_FragCoord.xy); - float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - - - fragColor = mix(color1, color2, u_fade) * alpha * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.fill_outline_pattern.vertex.glsl b/shaders/drawable.fill_outline_pattern.vertex.glsl deleted file mode 100644 index ebedb8cd0..000000000 --- a/shaders/drawable.fill_outline_pattern.vertex.glsl +++ /dev/null @@ -1,75 +0,0 @@ -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillOutlinePatternDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_tile_ratio; - // Interpolations - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_opacity_t; -}; - -layout (std140) uniform FillOutlinePatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -out vec2 v_pos_a; -out vec2 v_pos_b; -out vec2 v_pos; - -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp vec4 pattern_from -#pragma mapbox: define lowp vec4 pattern_to - -void main() { - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_pixel_ratio; - float tileRatio = u_tile_ratio; - float fromScale = u_from_scale; - float toScale = u_to_scale; - - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, a_pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, a_pos); - - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; -} diff --git a/shaders/drawable.fill_pattern.fragment.glsl b/shaders/drawable.fill_pattern.fragment.glsl deleted file mode 100644 index 37f2d0caa..000000000 --- a/shaders/drawable.fill_pattern.fragment.glsl +++ /dev/null @@ -1,54 +0,0 @@ -layout (std140) uniform FillPatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -uniform sampler2D u_image; - -in vec2 v_pos_a; -in vec2 v_pos_b; - -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp vec4 pattern_from -#pragma mapbox: define lowp vec4 pattern_to - -void main() { - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - if (u_texsize.x < 1.0 || u_texsize.y < 1.0) { - discard; - } - - vec2 imagecoord = mod(v_pos_a, 1.0); - vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture(u_image, pos); - - vec2 imagecoord_b = mod(v_pos_b, 1.0); - vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture(u_image, pos2); - - fragColor = mix(color1, color2, u_fade) * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.fill_pattern.vertex.glsl b/shaders/drawable.fill_pattern.vertex.glsl deleted file mode 100644 index 574ac994e..000000000 --- a/shaders/drawable.fill_pattern.vertex.glsl +++ /dev/null @@ -1,71 +0,0 @@ -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform FillPatternDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp float u_tile_ratio; - // Interpolations - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_opacity_t; -}; - -layout (std140) uniform FillPatternTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; - highp vec2 u_texsize; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform FillEvaluatedPropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; - highp float u_opacity; - highp float u_fade; - highp float u_from_scale; - highp float u_to_scale; -}; - -layout (location = 0) in vec2 a_pos; - -out vec2 v_pos_a; -out vec2 v_pos_b; - -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp vec4 pattern_from -#pragma mapbox: define lowp vec4 pattern_to - -void main() { - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_pixel_ratio; - float tileZoomRatio = u_tile_ratio; - float fromScale = u_from_scale; - float toScale = u_to_scale; - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, a_pos); - v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos); -} diff --git a/shaders/drawable.heatmap.fragment.glsl b/shaders/drawable.heatmap.fragment.glsl deleted file mode 100644 index d98ce5b8d..000000000 --- a/shaders/drawable.heatmap.fragment.glsl +++ /dev/null @@ -1,27 +0,0 @@ -in vec2 v_extrude; - -layout (std140) uniform HeatmapEvaluatedPropsUBO { - highp float u_weight; - highp float u_radius; - highp float u_intensity; - lowp float props_pad1; -}; - -#pragma mapbox: define highp float weight - -// Gaussian kernel coefficient: 1 / sqrt(2 * PI) -#define GAUSS_COEF 0.3989422804014327 - -void main() { - #pragma mapbox: initialize highp float weight - - // Kernel density estimation with a Gaussian kernel of size 5x5 - float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude); - float val = weight * u_intensity * GAUSS_COEF * exp(d); - - fragColor = vec4(val, 1.0, 1.0, 1.0); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.heatmap.vertex.glsl b/shaders/drawable.heatmap.vertex.glsl deleted file mode 100644 index 430b428b1..000000000 --- a/shaders/drawable.heatmap.vertex.glsl +++ /dev/null @@ -1,63 +0,0 @@ -layout (location = 0) in vec2 a_pos; -out vec2 v_extrude; - -layout (std140) uniform HeatmapDrawableUBO { - highp mat4 u_matrix; - highp float u_extrude_scale; - // Interpolations - lowp float u_weight_t; - lowp float u_radius_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform HeatmapEvaluatedPropsUBO { - highp float u_weight; - highp float u_radius; - highp float u_intensity; - lowp float props_pad1; -}; - -#pragma mapbox: define highp float weight -#pragma mapbox: define mediump float radius - -// Effective "0" in the kernel density texture to adjust the kernel size to; -// this empirically chosen number minimizes artifacts on overlapping kernels -// for typical heatmap cases (assuming clustered source) -const highp float ZERO = 1.0 / 255.0 / 16.0; - -// Gaussian kernel coefficient: 1 / sqrt(2 * PI) -#define GAUSS_COEF 0.3989422804014327 - -void main(void) { - #pragma mapbox: initialize highp float weight - #pragma mapbox: initialize mediump float radius - - // unencode the extrusion vector that we snuck into the a_pos vector - vec2 unscaled_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); - - // This 'extrude' comes in ranging from [-1, -1], to [1, 1]. We'll use - // it to produce the vertices of a square mesh framing the point feature - // we're adding to the kernel density texture. We'll also pass it as - // a varying, so that the fragment shader can determine the distance of - // each fragment from the point feature. - // Before we do so, we need to scale it up sufficiently so that the - // kernel falls effectively to zero at the edge of the mesh. - // That is, we want to know S such that - // weight * u_intensity * GAUSS_COEF * exp(-0.5 * 3.0^2 * S^2) == ZERO - // Which solves to: - // S = sqrt(-2.0 * log(ZERO / (weight * u_intensity * GAUSS_COEF))) / 3.0 - float S = sqrt(-2.0 * log(ZERO / weight / u_intensity / GAUSS_COEF)) / 3.0; - - // Pass the varying in units of radius - v_extrude = S * unscaled_extrude; - - // Scale by radius and the zoom-based scale factor to produce actual - // mesh position - vec2 extrude = v_extrude * radius * u_extrude_scale; - - // multiply a_pos by 0.5, since we had it * 2 in order to sneak - // in extrusion data - vec4 pos = vec4(floor(a_pos * 0.5) + extrude, 0, 1); - - gl_Position = u_matrix * pos; -} diff --git a/shaders/drawable.heatmap_texture.fragment.glsl b/shaders/drawable.heatmap_texture.fragment.glsl deleted file mode 100644 index b718394c1..000000000 --- a/shaders/drawable.heatmap_texture.fragment.glsl +++ /dev/null @@ -1,21 +0,0 @@ -in vec2 v_pos; -uniform sampler2D u_image; -uniform sampler2D u_color_ramp; - -layout (std140) uniform HeatmapTexturePropsUBO { - highp mat4 u_matrix; - highp float u_opacity; - lowp float props_pad1; - lowp float props_pad2; - lowp float props_pad3; -}; - -void main() { - float t = texture(u_image, v_pos).r; - vec4 color = texture(u_color_ramp, vec2(t, 0.5)); - fragColor = color * u_opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(0.0); -#endif -} diff --git a/shaders/drawable.heatmap_texture.vertex.glsl b/shaders/drawable.heatmap_texture.vertex.glsl deleted file mode 100644 index 714540473..000000000 --- a/shaders/drawable.heatmap_texture.vertex.glsl +++ /dev/null @@ -1,29 +0,0 @@ -layout (location = 0) in vec2 a_pos; -out vec2 v_pos; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform HeatmapTexturePropsUBO { - highp mat4 u_matrix; - highp float u_opacity; - lowp float props_pad1; - lowp float props_pad2; - lowp float props_pad3; -}; - -void main() { - gl_Position = u_matrix * vec4(a_pos * u_world_size, 0, 1); - - v_pos.x = a_pos.x; - v_pos.y = 1.0 - a_pos.y; -} diff --git a/shaders/drawable.hillshade.fragment.glsl b/shaders/drawable.hillshade.fragment.glsl deleted file mode 100644 index 499aa3c67..000000000 --- a/shaders/drawable.hillshade.fragment.glsl +++ /dev/null @@ -1,57 +0,0 @@ -in vec2 v_pos; -uniform sampler2D u_image; - -layout (std140) uniform HillshadeTilePropsUBO { - highp vec2 u_latrange; - highp vec2 u_light; -}; - -layout (std140) uniform HillshadeEvaluatedPropsUBO { - highp vec4 u_highlight; - highp vec4 u_shadow; - highp vec4 u_accent; -}; - -#define PI 3.141592653589793 - -void main() { - vec4 pixel = texture(u_image, v_pos); - - vec2 deriv = ((pixel.rg * 2.0) - 1.0); - - // We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude - // to account for mercator projection distortion. see #4807 for details - float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1])); - // We also multiply the slope by an arbitrary z-factor of 1.25 - float slope = atan(1.25 * length(deriv) / scaleFactor); - float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0); - - float intensity = u_light.x; - // We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal - // position property to account for 0deg corresponding to north/the top of the viewport in the style spec - // and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal. - float azimuth = u_light.y + PI; - - // We scale the slope exponentially based on intensity, using a calculation similar to - // the exponential interpolation function in the style spec: - // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/expression/definitions/interpolate.js#L217-L228 - // so that higher intensity values create more opaque hillshading. - float base = 1.875 - intensity * 1.75; - float maxValue = 0.5 * PI; - float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope; - - // The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine - // so that the accent color's rate of change eases in while the shade color's eases out. - float accent = cos(scaledSlope); - // We multiply both the accent and shade color by a clamped intensity value - // so that intensities >= 0.5 do not additionally affect the color values - // while intensity values < 0.5 make the overall color more transparent. - vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0); - float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0); - vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0); - fragColor = accent_color * (1.0 - shade_color.a) + shade_color; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.hillshade.vertex.glsl b/shaders/drawable.hillshade.vertex.glsl deleted file mode 100644 index acbc03803..000000000 --- a/shaders/drawable.hillshade.vertex.glsl +++ /dev/null @@ -1,13 +0,0 @@ -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_texture_pos; - -layout (std140) uniform HillshadeDrawableUBO { - highp mat4 u_matrix; -}; - -out vec2 v_pos; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos = a_texture_pos / 8192.0; -} diff --git a/shaders/drawable.hillshade_prepare.fragment.glsl b/shaders/drawable.hillshade_prepare.fragment.glsl deleted file mode 100644 index 9f7988750..000000000 --- a/shaders/drawable.hillshade_prepare.fragment.glsl +++ /dev/null @@ -1,77 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -in vec2 v_pos; -uniform sampler2D u_image; - -layout (std140) uniform HillshadePrepareTilePropsUBO { - highp vec4 u_unpack; - highp vec2 u_dimension; - highp float u_zoom; - highp float u_maxzoom; -}; - -float getElevation(vec2 coord, float bias) { - // Convert encoded elevation value to meters - vec4 data = texture(u_image, coord) * 255.0; - data.a = -1.0; - return dot(data, u_unpack) / 4.0; -} - -void main() { - vec2 epsilon = 1.0 / u_dimension; - - // queried pixels: - // +-----------+ - // | | | | - // | a | b | c | - // | | | | - // +-----------+ - // | | | | - // | d | e | f | - // | | | | - // +-----------+ - // | | | | - // | g | h | i | - // | | | | - // +-----------+ - - float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0); - float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0); - float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0); - float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0); - //float e = getElevation(v_pos, 0.0); - float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0); - float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0); - float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0); - float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0); - - // here we divide the x and y slopes by 8 * pixel size - // where pixel size (aka meters/pixel) is: - // circumference of the world / (pixels per tile * number of tiles) - // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom)) - // which can be reduced to: pow(2, 19.25619978527 - u_zoom) - // we want to vertically exaggerate the hillshading though, because otherwise - // it is barely noticeable at low zooms. to do this, we multiply this by some - // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value - // Here we use a=0.3 which works out to the expression below. see - // nickidlugash's awesome breakdown for more info - // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556 - float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3; - - vec2 deriv = vec2( - (c + f + f + i) - (a + d + d + g), - (g + h + h + i) - (a + b + b + c) - ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom); - - fragColor = clamp(vec4( - deriv.x / 2.0 + 0.5, - deriv.y / 2.0 + 0.5, - 1.0, - 1.0), 0.0, 1.0); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.hillshade_prepare.vertex.glsl b/shaders/drawable.hillshade_prepare.vertex.glsl deleted file mode 100644 index b917e86fd..000000000 --- a/shaders/drawable.hillshade_prepare.vertex.glsl +++ /dev/null @@ -1,23 +0,0 @@ -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_texture_pos; - -layout (std140) uniform HillshadePrepareDrawableUBO { - highp mat4 u_matrix; -}; - -layout (std140) uniform HillshadePrepareTilePropsUBO { - highp vec4 u_unpack; - highp vec2 u_dimension; - highp float u_zoom; - highp float u_maxzoom; -}; - -out vec2 v_pos; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - - highp vec2 epsilon = 1.0 / u_dimension; - float scale = (u_dimension.x - 2.0) / u_dimension.x; - v_pos = (a_texture_pos / 8192.0) * scale + epsilon; -} diff --git a/shaders/drawable.line.fragment.glsl b/shaders/drawable.line.fragment.glsl deleted file mode 100644 index 0d201bd28..000000000 --- a/shaders/drawable.line.fragment.glsl +++ /dev/null @@ -1,40 +0,0 @@ -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -in vec2 v_width2; -in vec2 v_normal; -in float v_gamma_scale; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity - -void main() { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - fragColor = color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.line.vertex.glsl b/shaders/drawable.line.vertex.glsl deleted file mode 100644 index 5dc5f8726..000000000 --- a/shaders/drawable.line.vertex.glsl +++ /dev/null @@ -1,117 +0,0 @@ -// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform LineDrawableUBO { - highp mat4 u_matrix; - mediump float u_ratio; - // Interpolations - lowp float u_color_t; - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_gapwidth_t; - lowp float u_offset_t; - lowp float u_width_t; - lowp float drawable_pad1; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out float v_gamma_scale; -out highp float v_linesofar; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump float gapwidth -#pragma mapbox: define lowp float offset -#pragma mapbox: define mediump float width - -void main() { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump float gapwidth - #pragma mapbox: initialize lowp float offset - #pragma mapbox: initialize mediump float width - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - - v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0; - - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist = outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_width2 = vec2(outset, inset); -} diff --git a/shaders/drawable.line_gradient.fragment.glsl b/shaders/drawable.line_gradient.fragment.glsl deleted file mode 100644 index a970705ab..000000000 --- a/shaders/drawable.line_gradient.fragment.glsl +++ /dev/null @@ -1,45 +0,0 @@ -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -in vec2 v_width2; -in vec2 v_normal; -in float v_gamma_scale; -in highp float v_lineprogress; - -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity - -void main() { - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - // For gradient lines, v_lineprogress is the ratio along the entire line, - // scaled to [0, 2^15), and the gradient ramp is stored in a texture. - vec4 color = texture(u_image, vec2(v_lineprogress, 0.5)); - - fragColor = color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.line_gradient.vertex.glsl b/shaders/drawable.line_gradient.vertex.glsl deleted file mode 100644 index f521a2270..000000000 --- a/shaders/drawable.line_gradient.vertex.glsl +++ /dev/null @@ -1,119 +0,0 @@ - -// the attribute conveying progress along a line is scaled to [0, 2^15) -#define MAX_LINE_DISTANCE 32767.0 - -// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform LineGradientDrawableUBO { - highp mat4 u_matrix; - mediump float u_ratio; - // Interpolations - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_gapwidth_t; - lowp float u_offset_t; - lowp float u_width_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out float v_gamma_scale; -out highp float v_lineprogress; - -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump float gapwidth -#pragma mapbox: define lowp float offset -#pragma mapbox: define mediump float width - -void main() { - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump float gapwidth - #pragma mapbox: initialize lowp float offset - #pragma mapbox: initialize mediump float width - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - - v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE; - - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist = outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_width2 = vec2(outset, inset); -} diff --git a/shaders/drawable.line_pattern.fragment.glsl b/shaders/drawable.line_pattern.fragment.glsl deleted file mode 100644 index 4fbcf49ec..000000000 --- a/shaders/drawable.line_pattern.fragment.glsl +++ /dev/null @@ -1,86 +0,0 @@ -layout (std140) uniform LinePatternTilePropsUBO { - lowp vec4 u_pattern_from; - lowp vec4 u_pattern_to; - mediump vec4 u_scale; - highp vec2 u_texsize; - highp float u_fade; - lowp float tileprops_pad1; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -in vec2 v_normal; -in vec2 v_width2; -in float v_linesofar; -in float v_gamma_scale; - -#pragma mapbox: define lowp vec4 pattern_from -#pragma mapbox: define lowp vec4 pattern_to -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity - -void main() { - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - - vec2 pattern_tl_a = pattern_from.xy; - vec2 pattern_br_a = pattern_from.zw; - vec2 pattern_tl_b = pattern_to.xy; - vec2 pattern_br_b = pattern_to.zw; - - float pixelRatio = u_scale.x; - float tileZoomRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; - - vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); - vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); - - vec2 pattern_size_a = vec2(display_size_a.x * fromScale / tileZoomRatio, display_size_a.y); - vec2 pattern_size_b = vec2(display_size_b.x * toScale / tileZoomRatio, display_size_b.y); - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - float x_a = mod(v_linesofar / pattern_size_a.x, 1.0); - float x_b = mod(v_linesofar / pattern_size_b.x, 1.0); - - // v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge - // we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0) - // to ensure we don't sample outside the designated symbol on the sprite sheet. - // 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of - // the texture coordinate - 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); - 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); - vec2 pos_a = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, vec2(x_a, y_a)); - vec2 pos_b = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, vec2(x_b, y_b)); - - vec4 color = mix(texture(u_image, pos_a), texture(u_image, pos_b), u_fade); - - fragColor = color * alpha * opacity; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.line_pattern.vertex.glsl b/shaders/drawable.line_pattern.vertex.glsl deleted file mode 100644 index c42ab953d..000000000 --- a/shaders/drawable.line_pattern.vertex.glsl +++ /dev/null @@ -1,131 +0,0 @@ -// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -// We scale the distance before adding it to the buffers so that we can store -// long distances for long segments. Use this value to unscale the distance. -#define LINE_DISTANCE_SCALE 2.0 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; -layout (std140) uniform LinePatternDrawableUBO { - highp mat4 u_matrix; - mediump float u_ratio; - // Interpolations - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_offset_t; - lowp float u_gapwidth_t; - lowp float u_width_t; - lowp float u_pattern_from_t; - lowp float u_pattern_to_t; -}; - -layout (std140) uniform LinePatternTilePropsUBO { - lowp vec4 u_pattern_from; - lowp vec4 u_pattern_to; - mediump vec4 u_scale; - highp vec2 u_texsize; - highp float u_fade; - lowp float tileprops_pad1; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out float v_linesofar; -out float v_gamma_scale; - -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp float offset -#pragma mapbox: define mediump float gapwidth -#pragma mapbox: define mediump float width -#pragma mapbox: define lowp vec4 pattern_from -#pragma mapbox: define lowp vec4 pattern_to - -void main() { - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize lowp float offset - #pragma mapbox: initialize mediump float gapwidth - #pragma mapbox: initialize mediump float width - #pragma mapbox: initialize mediump vec4 pattern_from - #pragma mapbox: initialize mediump vec4 pattern_to - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE; - // float tileRatio = u_scale.y; - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist = outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_linesofar = a_linesofar; - v_width2 = vec2(outset, inset); -} diff --git a/shaders/drawable.line_sdf.fragment.glsl b/shaders/drawable.line_sdf.fragment.glsl deleted file mode 100644 index 852f5f6d5..000000000 --- a/shaders/drawable.line_sdf.fragment.glsl +++ /dev/null @@ -1,60 +0,0 @@ -layout (std140) uniform LineSDFTilePropsUBO { - highp float u_sdfgamma; - highp float u_mix; - lowp float tileprops_pad1; - lowp float tileprops_pad2; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -uniform sampler2D u_image; - -in vec2 v_normal; -in vec2 v_width2; -in vec2 v_tex_a; -in vec2 v_tex_b; -in float v_gamma_scale; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump float width -#pragma mapbox: define lowp float floorwidth - -void main() { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump float width - #pragma mapbox: initialize lowp float floorwidth - - // Calculate the distance of the pixel from the line in pixels. - float dist = length(v_normal) * v_width2.s; - - // Calculate the antialiasing fade factor. This is either when fading in - // the line in case of an offset line (v_width2.t) or when fading out - // (v_width2.s) - float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; - float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - - float sdfdist_a = texture(u_image, v_tex_a).a; - float sdfdist_b = texture(u_image, v_tex_b).a; - float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix); - alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist); - - fragColor = color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.line_sdf.vertex.glsl b/shaders/drawable.line_sdf.vertex.glsl deleted file mode 100644 index 434498972..000000000 --- a/shaders/drawable.line_sdf.vertex.glsl +++ /dev/null @@ -1,132 +0,0 @@ -// floor(127 / 2) == 63.0 -// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is -// stored in a byte (-128..127). we scale regular normals up to length 63, but -// there are also "special" normals that have a bigger length (of up to 126 in -// this case). -// #define scale 63.0 -#define scale 0.015873016 - -// We scale the distance before adding it to the buffers so that we can store -// long distances for long segments. Use this value to unscale the distance. -#define LINE_DISTANCE_SCALE 2.0 - -layout (location = 0) in vec2 a_pos_normal; -layout (location = 1) in vec4 a_data; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform LineSDFDrawableUBO { - highp mat4 u_matrix; - highp vec2 u_patternscale_a; - highp vec2 u_patternscale_b; - highp float u_tex_y_a; - highp float u_tex_y_b; - mediump float u_ratio; - // Interpolations - lowp float u_color_t; - lowp float u_blur_t; - lowp float u_opacity_t; - lowp float u_gapwidth_t; - lowp float u_offset_t; - lowp float u_width_t; - lowp float u_floorwidth_t; - lowp float drawable_pad1; - lowp float drawable_pad2; -}; - -layout (std140) uniform LineEvaluatedPropsUBO { - highp vec4 u_color; - lowp float u_blur; - lowp float u_opacity; - mediump float u_gapwidth; - lowp float u_offset; - mediump float u_width; - lowp float u_floorwidth; - lowp float props_pad1; - lowp float props_pad2; -}; - -out vec2 v_normal; -out vec2 v_width2; -out vec2 v_tex_a; -out vec2 v_tex_b; -out float v_gamma_scale; - -#pragma mapbox: define highp vec4 color -#pragma mapbox: define lowp float blur -#pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump float gapwidth -#pragma mapbox: define lowp float offset -#pragma mapbox: define mediump float width -#pragma mapbox: define lowp float floorwidth - -void main() { - #pragma mapbox: initialize highp vec4 color - #pragma mapbox: initialize lowp float blur - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize mediump float gapwidth - #pragma mapbox: initialize lowp float offset - #pragma mapbox: initialize mediump float width - #pragma mapbox: initialize lowp float floorwidth - - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; - - vec2 a_extrude = a_data.xy - 128.0; - float a_direction = mod(a_data.z, 4.0) - 1.0; - float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE; - - vec2 pos = floor(a_pos_normal * 0.5); - - // x is 1 if it's a round cap, 0 otherwise - // y is 1 if the normal points up, and -1 if it points down - // We store these in the least significant bit of a_pos_normal - mediump vec2 normal = a_pos_normal - 2.0 * pos; - normal.y = normal.y * 2.0 - 1.0; - v_normal = normal; - - // these transformations used to be applied in the JS and native code bases. - // moved them into the shader for clarity and simplicity. - gapwidth = gapwidth / 2.0; - float halfwidth = width / 2.0; - offset = -1.0 * offset; - - float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); - float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); - - // Scale the extrusion vector down to a normal and then up by the line width - // of this vertex. - mediump vec2 dist =outset * a_extrude * scale; - - // Calculate the offset when drawing a line that is to the side of the actual line. - // We do this by creating a vector that points towards the extrude, but rotate - // it when we're drawing round end points (a_direction = -1 or 1) since their - // extrude vector points in another direction. - mediump float u = 0.5 * a_direction; - mediump float t = 1.0 - abs(u); - mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); - - vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); - gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; - - // calculate how much the perspective view squishes or stretches the extrude - float extrude_length_without_perspective = length(dist); - float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); - v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; - - v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a); - v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b); - - v_width2 = vec2(outset, inset); -} diff --git a/shaders/drawable.raster.fragment.glsl b/shaders/drawable.raster.fragment.glsl deleted file mode 100644 index 352cf5a00..000000000 --- a/shaders/drawable.raster.fragment.glsl +++ /dev/null @@ -1,58 +0,0 @@ -layout (std140) uniform RasterEvaluatedPropsUBO { - highp vec3 u_spin_weights; - highp vec2 u_tl_parent; - highp float u_scale_parent; - highp float u_buffer_scale; - highp float u_fade_t; - highp float u_opacity; - highp float u_brightness_low; - highp float u_brightness_high; - highp float u_saturation_factor; - highp float u_contrast_factor; - lowp float props_pad1; - lowp float props_pad2; -}; -uniform sampler2D u_image0; -uniform sampler2D u_image1; - -in vec2 v_pos0; -in vec2 v_pos1; - -void main() { - - // read and cross-fade colors from the main and parent tiles - vec4 color0 = texture(u_image0, v_pos0); - vec4 color1 = texture(u_image1, v_pos1); - if (color0.a > 0.0) { - color0.rgb = color0.rgb / color0.a; - } - if (color1.a > 0.0) { - color1.rgb = color1.rgb / color1.a; - } - vec4 color = mix(color0, color1, u_fade_t); - color.a *= u_opacity; - vec3 rgb = color.rgb; - - // spin - rgb = vec3( - dot(rgb, u_spin_weights.xyz), - dot(rgb, u_spin_weights.zxy), - dot(rgb, u_spin_weights.yzx)); - - // saturation - float average = (color.r + color.g + color.b) / 3.0; - rgb += (average - rgb) * u_saturation_factor; - - // contrast - rgb = (rgb - 0.5) * u_contrast_factor + 0.5; - - // brightness - vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low); - vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high); - - fragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.raster.vertex.glsl b/shaders/drawable.raster.vertex.glsl deleted file mode 100644 index 331f376fe..000000000 --- a/shaders/drawable.raster.vertex.glsl +++ /dev/null @@ -1,34 +0,0 @@ -layout (std140) uniform RasterDrawableUBO { - highp mat4 u_matrix; -}; -layout (std140) uniform RasterEvaluatedPropsUBO { - highp vec3 u_spin_weights; - highp vec2 u_tl_parent; - highp float u_scale_parent; - highp float u_buffer_scale; - highp float u_fade_t; - highp float u_opacity; - highp float u_brightness_low; - highp float u_brightness_high; - highp float u_saturation_factor; - highp float u_contrast_factor; - lowp float props_pad1; - lowp float props_pad2; -}; - -layout (location = 0) in vec2 a_pos; -layout (location = 1) in vec2 a_texture_pos; - -out vec2 v_pos0; -out vec2 v_pos1; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); - // We are using Int16 for texture position coordinates to give us enough precision for - // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer - // as an arbitrarily high number to preserve adequate precision when rendering. - // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates, - // so math for modifying either is consistent. - v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5; - v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent; -} diff --git a/shaders/drawable.symbol_icon.fragment.glsl b/shaders/drawable.symbol_icon.fragment.glsl deleted file mode 100644 index ce3a301d5..000000000 --- a/shaders/drawable.symbol_icon.fragment.glsl +++ /dev/null @@ -1,41 +0,0 @@ -uniform sampler2D u_texture; - -layout (std140) uniform SymbolTilePropsUBO { - bool u_is_text; - bool u_is_halo; - highp float u_gamma_scale; - lowp float tileprops_pad1; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -in vec2 v_tex; -in float v_fade_opacity; - -#pragma mapbox: define lowp float opacity - -void main() { - highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; - - #pragma mapbox: initialize lowp float opacity - - lowp float alpha = opacity * v_fade_opacity; - fragColor = texture(u_texture, v_tex) * alpha; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.symbol_icon.vertex.glsl b/shaders/drawable.symbol_icon.vertex.glsl deleted file mode 100644 index 678f3323b..000000000 --- a/shaders/drawable.symbol_icon.vertex.glsl +++ /dev/null @@ -1,127 +0,0 @@ -layout (location = 0) in vec4 a_pos_offset; -layout (location = 1) in vec4 a_data; -layout (location = 2) in vec4 a_pixeloffset; -layout (location = 3) in vec3 a_projected_pos; -layout (location = 4) in float a_fade_opacity; - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform SymbolDrawableUBO { - highp mat4 u_matrix; - highp mat4 u_label_plane_matrix; - highp mat4 u_coord_matrix; - - highp vec2 u_texsize; - highp vec2 u_texsize_icon; - - bool u_is_text_prop; - bool u_rotate_symbol; - bool u_pitch_with_map; - bool u_is_size_zoom_constant; - bool u_is_size_feature_constant; - - highp float u_size_t; // used to interpolate between zoom stops when size is a composite function - highp float u_size; // used when size is both zoom and feature constant - - // Interpolations - highp float u_fill_color_t; - highp float u_halo_color_t; - highp float u_opacity_t; - highp float u_halo_width_t; - highp float u_halo_blur_t; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -out vec2 v_tex; -out float v_fade_opacity; - -#pragma mapbox: define lowp float opacity - -void main() { - highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; - - #pragma mapbox: initialize lowp float opacity - - vec2 a_pos = a_pos_offset.xy; - vec2 a_offset = a_pos_offset.zw; - - vec2 a_tex = a_data.xy; - vec2 a_size = a_data.zw; - - float a_size_min = floor(a_size[0] * 0.5); - vec2 a_pxoffset = a_pixeloffset.xy; - vec2 a_minFontScale = a_pixeloffset.zw / 256.0; - - highp float segment_angle = -a_projected_pos[2]; - float size; - - if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = mix(a_size_min, a_size[1], u_size_t) / 128.0; - } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = a_size_min / 128.0; - } else { - size = u_size; - } - - vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1); - highp float camera_to_anchor_distance = projectedPoint.w; - // See comments in symbol_sdf.vertex - 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 = clamp( - 0.5 + 0.5 * distance_ratio, - 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles - 4.0); - - size *= perspective_ratio; - - float fontScale = u_is_text_prop ? size / 24.0 : size; - - highp float symbol_rotation = 0.0; - if (u_rotate_symbol) { - // See comments in symbol_sdf.vertex - vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); - - vec2 a = projectedPoint.xy / projectedPoint.w; - vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; - - symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); - } - - highp float angle_sin = sin(segment_angle + symbol_rotation); - highp float angle_cos = cos(segment_angle + symbol_rotation); - mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); - - vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); - gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * max(a_minFontScale, fontScale) + a_pxoffset / 16.0), 0.0, 1.0); - - v_tex = a_tex / u_texsize; - vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; - v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); -} diff --git a/shaders/drawable.symbol_sdf.fragment.glsl b/shaders/drawable.symbol_sdf.fragment.glsl deleted file mode 100644 index 6bc97ac3e..000000000 --- a/shaders/drawable.symbol_sdf.fragment.glsl +++ /dev/null @@ -1,76 +0,0 @@ -#define SDF_PX 8.0 - -layout (std140) uniform SymbolTilePropsUBO { - bool u_is_text; - bool u_is_halo; - highp float u_gamma_scale; - lowp float tileprops_pad1; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -uniform sampler2D u_texture; - -in vec2 v_data0; -in vec3 v_data1; - -#pragma mapbox: define highp vec4 fill_color -#pragma mapbox: define highp vec4 halo_color -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp float halo_width -#pragma mapbox: define lowp float halo_blur - -void main() { - highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color; - highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color; - highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; - highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width; - highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur; - - #pragma mapbox: initialize highp vec4 fill_color - #pragma mapbox: initialize highp vec4 halo_color - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize lowp float halo_width - #pragma mapbox: initialize lowp float halo_blur - - float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO; - - vec2 tex = v_data0.xy; - float gamma_scale = v_data1.x; - float size = v_data1.y; - float fade_opacity = v_data1[2]; - - float fontScale = u_is_text ? size / 24.0 : size; - - lowp vec4 color = fill_color; - highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale); - lowp float buff = (256.0 - 64.0) / 256.0; - if (u_is_halo) { - color = halo_color; - gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale); - buff = (6.0 - halo_width / fontScale) / SDF_PX; - } - - lowp float dist = texture(u_texture, tex).a; - highp float gamma_scaled = gamma * gamma_scale; - highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - - fragColor = color * (alpha * opacity * fade_opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.symbol_sdf.vertex.glsl b/shaders/drawable.symbol_sdf.vertex.glsl deleted file mode 100644 index 6c94980d7..000000000 --- a/shaders/drawable.symbol_sdf.vertex.glsl +++ /dev/null @@ -1,156 +0,0 @@ -layout (location = 0) in vec4 a_pos_offset; -layout (location = 1) in vec4 a_data; -layout (location = 2) in vec4 a_pixeloffset; -layout (location = 3) in vec3 a_projected_pos; -layout (location = 4) in float a_fade_opacity; - -// contents of a_size vary based on the type of property value -// used for {text,icon}-size. -// For constants, a_size is disabled. -// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature. -// For composite functions: -// [ text-size(lowerZoomStop, feature), -// text-size(upperZoomStop, feature) ] - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform SymbolDrawableUBO { - highp mat4 u_matrix; - highp mat4 u_label_plane_matrix; - highp mat4 u_coord_matrix; - - highp vec2 u_texsize; - highp vec2 u_texsize_icon; - - bool u_is_text_prop; - bool u_rotate_symbol; - bool u_pitch_with_map; - bool u_is_size_zoom_constant; - bool u_is_size_feature_constant; - - highp float u_size_t; // used to interpolate between zoom stops when size is a composite function - highp float u_size; // used when size is both zoom and feature constant - - // Interpolations - highp float u_fill_color_t; - highp float u_halo_color_t; - highp float u_opacity_t; - highp float u_halo_width_t; - highp float u_halo_blur_t; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -out vec2 v_data0; -out vec3 v_data1; - -#pragma mapbox: define highp vec4 fill_color -#pragma mapbox: define highp vec4 halo_color -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp float halo_width -#pragma mapbox: define lowp float halo_blur - -void main() { - highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color; - highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color; - highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; - highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width; - highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur; - - #pragma mapbox: initialize highp vec4 fill_color - #pragma mapbox: initialize highp vec4 halo_color - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize lowp float halo_width - #pragma mapbox: initialize lowp float halo_blur - - vec2 a_pos = a_pos_offset.xy; - vec2 a_offset = a_pos_offset.zw; - - vec2 a_tex = a_data.xy; - vec2 a_size = a_data.zw; - - float a_size_min = floor(a_size[0] * 0.5); - vec2 a_pxoffset = a_pixeloffset.xy; - - highp float segment_angle = -a_projected_pos[2]; - float size; - - if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = mix(a_size_min, a_size[1], u_size_t) / 128.0; - } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = a_size_min / 128.0; - } else { - size = u_size; - } - - vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1); - highp float camera_to_anchor_distance = projectedPoint.w; - // If the label is pitched with the map, layout is done in pitched space, - // which makes labels in the distance smaller relative to viewport space. - // We counteract part of that effect by multiplying by the perspective ratio. - // If the label isn't pitched with the map, we do layout in viewport space, - // which makes labels in the distance larger relative to the features around - // them. We counteract part of that effect by dividing by the perspective ratio. - 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 = clamp( - 0.5 + 0.5 * distance_ratio, - 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles - 4.0); - - size *= perspective_ratio; - - float fontScale = u_is_text_prop ? size / 24.0 : size; - - highp float symbol_rotation = 0.0; - if (u_rotate_symbol) { - // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units - // To figure out that angle in projected space, we draw a short horizontal line in tile - // space, project it, and measure its angle in projected space. - vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); - - vec2 a = projectedPoint.xy / projectedPoint.w; - vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; - - symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); - } - - highp float angle_sin = sin(segment_angle + symbol_rotation); - highp float angle_cos = cos(segment_angle + symbol_rotation); - mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); - - vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); - gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset), 0.0, 1.0); - float gamma_scale = gl_Position.w; - - vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; - float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); - - v_data0 = a_tex / u_texsize; - v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity); -} diff --git a/shaders/drawable.symbol_text_and_icon.fragment.glsl b/shaders/drawable.symbol_text_and_icon.fragment.glsl deleted file mode 100644 index 8c307d0f0..000000000 --- a/shaders/drawable.symbol_text_and_icon.fragment.glsl +++ /dev/null @@ -1,93 +0,0 @@ -#define SDF_PX 8.0 - -#define SDF 1.0 -#define ICON 0.0 - -layout (std140) uniform SymbolTilePropsUBO { - bool u_is_text; - bool u_is_halo; - highp float u_gamma_scale; - lowp float tileprops_pad1; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -uniform sampler2D u_texture; -uniform sampler2D u_texture_icon; - -in vec4 v_data0; -in vec4 v_data1; - -#pragma mapbox: define highp vec4 fill_color -#pragma mapbox: define highp vec4 halo_color -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp float halo_width -#pragma mapbox: define lowp float halo_blur - -void main() { - highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color; - highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color; - highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; - highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width; - highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur; - - #pragma mapbox: initialize highp vec4 fill_color - #pragma mapbox: initialize highp vec4 halo_color - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize lowp float halo_width - #pragma mapbox: initialize lowp float halo_blur - - float fade_opacity = v_data1[2]; - - if (v_data1.w == ICON) { - vec2 tex_icon = v_data0.zw; - lowp float alpha = opacity * fade_opacity; - fragColor = texture(u_texture_icon, tex_icon) * alpha; - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif - return; - } - - vec2 tex = v_data0.xy; - - float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO; - - float gamma_scale = v_data1.x; - float size = v_data1.y; - - float fontScale = size / 24.0; - - lowp vec4 color = fill_color; - highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale); - lowp float buff = (256.0 - 64.0) / 256.0; - if (u_is_halo) { - color = halo_color; - gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale); - buff = (6.0 - halo_width / fontScale) / SDF_PX; - } - - lowp float dist = texture(u_texture, tex).a; - highp float gamma_scaled = gamma * gamma_scale; - highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - - fragColor = color * (alpha * opacity * fade_opacity); - -#ifdef OVERDRAW_INSPECTOR - fragColor = vec4(1.0); -#endif -} diff --git a/shaders/drawable.symbol_text_and_icon.vertex.glsl b/shaders/drawable.symbol_text_and_icon.vertex.glsl deleted file mode 100644 index 6035d4512..000000000 --- a/shaders/drawable.symbol_text_and_icon.vertex.glsl +++ /dev/null @@ -1,156 +0,0 @@ -layout (location = 0) in vec4 a_pos_offset; -layout (location = 1) in vec4 a_data; -layout (location = 2) in vec3 a_projected_pos; -layout (location = 3) in float a_fade_opacity; - -// contents of a_size vary based on the type of property value -// used for {text,icon}-size. -// For constants, a_size is disabled. -// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature. -// For composite functions: -// [ text-size(lowerZoomStop, feature), -// text-size(upperZoomStop, feature) ] - -layout (std140) uniform GlobalPaintParamsUBO { - highp vec2 u_pattern_atlas_texsize; - highp vec2 u_units_to_pixels; - highp vec2 u_world_size; - highp float u_camera_to_center_distance; - highp float u_symbol_fade_change; - highp float u_aspect_ratio; - highp float u_pixel_ratio; - highp float u_map_zoom; - lowp float global_pad1; -}; - -layout (std140) uniform SymbolDrawableUBO { - highp mat4 u_matrix; - highp mat4 u_label_plane_matrix; - highp mat4 u_coord_matrix; - - highp vec2 u_texsize; - highp vec2 u_texsize_icon; - - bool u_is_text_prop; - bool u_rotate_symbol; - bool u_pitch_with_map; - bool u_is_size_zoom_constant; - bool u_is_size_feature_constant; - - highp float u_size_t; // used to interpolate between zoom stops when size is a composite function - highp float u_size; // used when size is both zoom and feature constant - - // Interpolations - highp float u_fill_color_t; - highp float u_halo_color_t; - highp float u_opacity_t; - highp float u_halo_width_t; - highp float u_halo_blur_t; -}; - -layout (std140) uniform SymbolEvaluatedPropsUBO { - highp vec4 u_text_fill_color; - highp vec4 u_text_halo_color; - highp float u_text_opacity; - highp float u_text_halo_width; - highp float u_text_halo_blur; - lowp float props_pad1; - highp vec4 u_icon_fill_color; - highp vec4 u_icon_halo_color; - highp float u_icon_opacity; - highp float u_icon_halo_width; - highp float u_icon_halo_blur; - lowp float props_pad2; -}; - -out vec4 v_data0; -out vec4 v_data1; - -#pragma mapbox: define highp vec4 fill_color -#pragma mapbox: define highp vec4 halo_color -#pragma mapbox: define lowp float opacity -#pragma mapbox: define lowp float halo_width -#pragma mapbox: define lowp float halo_blur - -void main() { - highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color; - highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color; - highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; - highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width; - highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur; - - #pragma mapbox: initialize highp vec4 fill_color - #pragma mapbox: initialize highp vec4 halo_color - #pragma mapbox: initialize lowp float opacity - #pragma mapbox: initialize lowp float halo_width - #pragma mapbox: initialize lowp float halo_blur - - vec2 a_pos = a_pos_offset.xy; - vec2 a_offset = a_pos_offset.zw; - - vec2 a_tex = a_data.xy; - vec2 a_size = a_data.zw; - - float a_size_min = floor(a_size[0] * 0.5); - float is_sdf = a_size[0] - 2.0 * a_size_min; - - highp float segment_angle = -a_projected_pos[2]; - float size; - - if (!u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = mix(a_size_min, a_size[1], u_size_t) / 128.0; - } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) { - size = a_size_min / 128.0; - } else { - size = u_size; - } - - vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1); - highp float camera_to_anchor_distance = projectedPoint.w; - // If the label is pitched with the map, layout is done in pitched space, - // which makes labels in the distance smaller relative to viewport space. - // We counteract part of that effect by multiplying by the perspective ratio. - // If the label isn't pitched with the map, we do layout in viewport space, - // which makes labels in the distance larger relative to the features around - // them. We counteract part of that effect by dividing by the perspective ratio. - 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 = clamp( - 0.5 + 0.5 * distance_ratio, - 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles - 4.0); - - size *= perspective_ratio; - - float fontScale = size / 24.0; - - highp float symbol_rotation = 0.0; - if (u_rotate_symbol) { - // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units - // To figure out that angle in projected space, we draw a short horizontal line in tile - // space, project it, and measure its angle in projected space. - vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1); - - vec2 a = projectedPoint.xy / projectedPoint.w; - vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w; - - symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x); - } - - highp float angle_sin = sin(segment_angle + symbol_rotation); - highp float angle_cos = cos(segment_angle + symbol_rotation); - mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos); - - vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0); - gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0); - float gamma_scale = gl_Position.w; - - vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; - float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); - - v_data0.xy = a_tex / u_texsize; - v_data0.zw = a_tex / u_texsize_icon; - v_data1 = vec4(gamma_scale, size, interpolated_fade_opacity, is_sdf); -} diff --git a/shaders/fill.fragment.glsl b/shaders/fill.fragment.glsl index ffd33c16c..cd2d2aa4a 100644 --- a/shaders/fill.fragment.glsl +++ b/shaders/fill.fragment.glsl @@ -1,3 +1,12 @@ +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity diff --git a/shaders/fill.vertex.glsl b/shaders/fill.vertex.glsl index 7a1db6382..f77883221 100644 --- a/shaders/fill.vertex.glsl +++ b/shaders/fill.vertex.glsl @@ -1,6 +1,22 @@ -layout (location = 0) in vec2 a_pos; +layout (std140) uniform FillDrawableUBO { + highp mat4 u_matrix; + // Interpolations + highp float u_color_t; + highp float u_opacity_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; -uniform mat4 u_matrix; +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + +layout (location = 0) in vec2 a_pos; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity diff --git a/shaders/fill_extrusion.vertex.glsl b/shaders/fill_extrusion.vertex.glsl index dda699133..ae4dc60fd 100644 --- a/shaders/fill_extrusion.vertex.glsl +++ b/shaders/fill_extrusion.vertex.glsl @@ -1,14 +1,46 @@ -uniform mat4 u_matrix; -uniform vec3 u_lightcolor; -uniform lowp vec3 u_lightpos; -uniform lowp float u_lightintensity; -uniform float u_vertical_gradient; -uniform lowp float u_opacity; - layout (location = 0) in vec2 a_pos; layout (location = 1) in vec4 a_normal_ed; out vec4 v_color; +layout (std140) uniform FillExtrusionDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_height_factor; + highp float u_tile_ratio; + // Interpolations + highp float u_base_t; + highp float u_height_t; + highp float u_color_t; + highp float u_pattern_from_t; + highp float u_pattern_to_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform FillExtrusionTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillExtrusionPropsUBO { + highp vec4 u_color; + highp vec3 u_lightcolor; + lowp float props_pad1; + highp vec3 u_lightpos; + highp float u_base; + highp float u_height; + highp float u_lightintensity; + highp float u_vertical_gradient; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; + lowp float props_pad2; +}; + #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color diff --git a/shaders/fill_extrusion_pattern.fragment.glsl b/shaders/fill_extrusion_pattern.fragment.glsl index 1e0638012..a4ce886e3 100644 --- a/shaders/fill_extrusion_pattern.fragment.glsl +++ b/shaders/fill_extrusion_pattern.fragment.glsl @@ -1,12 +1,33 @@ -uniform vec2 u_texsize; -uniform float u_fade; - -uniform sampler2D u_image; - in vec2 v_pos_a; in vec2 v_pos_b; in vec4 v_lighting; +layout (std140) uniform FillExtrusionTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillExtrusionPropsUBO { + highp vec4 u_color; + highp vec3 u_lightcolor; + lowp float props_pad1; + highp vec3 u_lightpos; + highp float u_base; + highp float u_height; + highp float u_lightintensity; + highp float u_vertical_gradient; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; + lowp float props_pad2; +}; + +uniform sampler2D u_image; + #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define mediump vec4 pattern_from diff --git a/shaders/fill_extrusion_pattern.vertex.glsl b/shaders/fill_extrusion_pattern.vertex.glsl index 459cf8baa..71645f7f3 100644 --- a/shaders/fill_extrusion_pattern.vertex.glsl +++ b/shaders/fill_extrusion_pattern.vertex.glsl @@ -1,15 +1,3 @@ -uniform mat4 u_matrix; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform float u_height_factor; -uniform vec4 u_scale; -uniform float u_vertical_gradient; -uniform lowp float u_opacity; - -uniform vec3 u_lightcolor; -uniform lowp vec3 u_lightpos; -uniform lowp float u_lightintensity; - layout (location = 0) in vec2 a_pos; layout (location = 1) in vec4 a_normal_ed; @@ -17,6 +5,57 @@ out vec2 v_pos_a; out vec2 v_pos_b; out vec4 v_lighting; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform FillExtrusionDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_height_factor; + highp float u_tile_ratio; + // Interpolations + highp float u_base_t; + highp float u_height_t; + highp float u_color_t; + highp float u_pattern_from_t; + highp float u_pattern_to_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform FillExtrusionTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillExtrusionPropsUBO { + highp vec4 u_color; + highp vec3 u_lightcolor; + lowp float props_pad1; + highp vec3 u_lightpos; + highp float u_base; + highp float u_height; + highp float u_lightintensity; + highp float u_vertical_gradient; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; + lowp float props_pad2; +}; + #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define mediump vec4 pattern_from @@ -33,10 +72,10 @@ void main() { vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; - float pixelRatio = u_scale.x; - float tileRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; + float pixelRatio = u_pixel_ratio; + float tileRatio = u_tile_ratio; + float fromScale = u_from_scale; + float toScale = u_to_scale; vec3 normal = a_normal_ed.xyz; float edgedistance = a_normal_ed.w; diff --git a/shaders/fill_outline.fragment.glsl b/shaders/fill_outline.fragment.glsl index f13b94eda..eacab7664 100644 --- a/shaders/fill_outline.fragment.glsl +++ b/shaders/fill_outline.fragment.glsl @@ -1,3 +1,12 @@ +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + in vec2 v_pos; #pragma mapbox: define highp vec4 outline_color diff --git a/shaders/fill_outline.vertex.glsl b/shaders/fill_outline.vertex.glsl index dea871d58..50dadb4c3 100644 --- a/shaders/fill_outline.vertex.glsl +++ b/shaders/fill_outline.vertex.glsl @@ -1,7 +1,34 @@ -layout (location = 0) in vec2 a_pos; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; -uniform mat4 u_matrix; -uniform vec2 u_world; +layout (std140) uniform FillOutlineDrawableUBO { + highp mat4 u_matrix; + // Interpolations + highp float u_outline_color_t; + highp float u_opacity_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; + +layout (location = 0) in vec2 a_pos; out vec2 v_pos; @@ -13,5 +40,5 @@ void main() { #pragma mapbox: initialize lowp float opacity gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; + v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; } diff --git a/shaders/fill_outline_pattern.fragment.glsl b/shaders/fill_outline_pattern.fragment.glsl index 031d8d648..7e6175401 100644 --- a/shaders/fill_outline_pattern.fragment.glsl +++ b/shaders/fill_outline_pattern.fragment.glsl @@ -1,15 +1,29 @@ +layout (std140) uniform FillOutlinePatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; -uniform vec2 u_texsize; uniform sampler2D u_image; -uniform float u_fade; in vec2 v_pos_a; in vec2 v_pos_b; in vec2 v_pos; #pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity diff --git a/shaders/fill_outline_pattern.vertex.glsl b/shaders/fill_outline_pattern.vertex.glsl index aa75f7865..ebedb8cd0 100644 --- a/shaders/fill_outline_pattern.vertex.glsl +++ b/shaders/fill_outline_pattern.vertex.glsl @@ -1,8 +1,42 @@ -uniform mat4 u_matrix; -uniform vec2 u_world; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform vec4 u_scale; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform FillOutlinePatternDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_tile_ratio; + // Interpolations + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; +}; + +layout (std140) uniform FillOutlinePatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; layout (location = 0) in vec2 a_pos; @@ -11,8 +45,8 @@ out vec2 v_pos_b; out vec2 v_pos; #pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity @@ -24,10 +58,10 @@ void main() { vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; - float pixelRatio = u_scale.x; - float tileRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; + float pixelRatio = u_pixel_ratio; + float tileRatio = u_tile_ratio; + float fromScale = u_from_scale; + float toScale = u_to_scale; gl_Position = u_matrix * vec4(a_pos, 0, 1); @@ -37,5 +71,5 @@ void main() { v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, a_pos); v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, a_pos); - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; + v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size; } diff --git a/shaders/drawable.fill_outline_triangulated.fragment.glsl b/shaders/fill_outline_triangulated.fragment.glsl similarity index 100% rename from shaders/drawable.fill_outline_triangulated.fragment.glsl rename to shaders/fill_outline_triangulated.fragment.glsl diff --git a/shaders/drawable.fill_outline_triangulated.vertex.glsl b/shaders/fill_outline_triangulated.vertex.glsl similarity index 100% rename from shaders/drawable.fill_outline_triangulated.vertex.glsl rename to shaders/fill_outline_triangulated.vertex.glsl diff --git a/shaders/fill_pattern.fragment.glsl b/shaders/fill_pattern.fragment.glsl index 9624f8de7..37f2d0caa 100644 --- a/shaders/fill_pattern.fragment.glsl +++ b/shaders/fill_pattern.fragment.glsl @@ -1,5 +1,19 @@ -uniform vec2 u_texsize; -uniform float u_fade; +layout (std140) uniform FillPatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; uniform sampler2D u_image; @@ -7,8 +21,8 @@ in vec2 v_pos_a; in vec2 v_pos_b; #pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity @@ -20,6 +34,10 @@ void main() { vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; + if (u_texsize.x < 1.0 || u_texsize.y < 1.0) { + discard; + } + vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); vec4 color1 = texture(u_image, pos); diff --git a/shaders/fill_pattern.vertex.glsl b/shaders/fill_pattern.vertex.glsl index f3a5f891f..574ac994e 100644 --- a/shaders/fill_pattern.vertex.glsl +++ b/shaders/fill_pattern.vertex.glsl @@ -1,7 +1,42 @@ -uniform mat4 u_matrix; -uniform vec2 u_pixel_coord_upper; -uniform vec2 u_pixel_coord_lower; -uniform vec4 u_scale; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform FillPatternDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_pixel_coord_upper; + highp vec2 u_pixel_coord_lower; + highp float u_tile_ratio; + // Interpolations + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; +}; + +layout (std140) uniform FillPatternTilePropsUBO { + highp vec4 u_pattern_from; + highp vec4 u_pattern_to; + highp vec2 u_texsize; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform FillEvaluatedPropsUBO { + highp vec4 u_color; + highp vec4 u_outline_color; + highp float u_opacity; + highp float u_fade; + highp float u_from_scale; + highp float u_to_scale; +}; layout (location = 0) in vec2 a_pos; @@ -9,8 +44,8 @@ out vec2 v_pos_a; out vec2 v_pos_b; #pragma mapbox: define lowp float opacity -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity @@ -22,10 +57,10 @@ void main() { vec2 pattern_tl_b = pattern_to.xy; vec2 pattern_br_b = pattern_to.zw; - float pixelRatio = u_scale.x; - float tileZoomRatio = u_scale.y; - float fromScale = u_scale.z; - float toScale = u_scale.w; + float pixelRatio = u_pixel_ratio; + float tileZoomRatio = u_tile_ratio; + float fromScale = u_from_scale; + float toScale = u_to_scale; vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); diff --git a/shaders/heatmap.fragment.glsl b/shaders/heatmap.fragment.glsl index bd6aaa517..d98ce5b8d 100644 --- a/shaders/heatmap.fragment.glsl +++ b/shaders/heatmap.fragment.glsl @@ -1,7 +1,12 @@ -uniform highp float u_intensity; - in vec2 v_extrude; +layout (std140) uniform HeatmapEvaluatedPropsUBO { + highp float u_weight; + highp float u_radius; + highp float u_intensity; + lowp float props_pad1; +}; + #pragma mapbox: define highp float weight // Gaussian kernel coefficient: 1 / sqrt(2 * PI) diff --git a/shaders/heatmap.vertex.glsl b/shaders/heatmap.vertex.glsl index e51b39d63..430b428b1 100644 --- a/shaders/heatmap.vertex.glsl +++ b/shaders/heatmap.vertex.glsl @@ -1,11 +1,22 @@ -uniform mat4 u_matrix; -uniform float u_extrude_scale; -uniform float u_opacity; -uniform float u_intensity; - layout (location = 0) in vec2 a_pos; out vec2 v_extrude; +layout (std140) uniform HeatmapDrawableUBO { + highp mat4 u_matrix; + highp float u_extrude_scale; + // Interpolations + lowp float u_weight_t; + lowp float u_radius_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform HeatmapEvaluatedPropsUBO { + highp float u_weight; + highp float u_radius; + highp float u_intensity; + lowp float props_pad1; +}; + #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius diff --git a/shaders/heatmap_texture.fragment.glsl b/shaders/heatmap_texture.fragment.glsl index 3eed37b1f..b718394c1 100644 --- a/shaders/heatmap_texture.fragment.glsl +++ b/shaders/heatmap_texture.fragment.glsl @@ -1,7 +1,14 @@ +in vec2 v_pos; uniform sampler2D u_image; uniform sampler2D u_color_ramp; -uniform float u_opacity; -in vec2 v_pos; + +layout (std140) uniform HeatmapTexturePropsUBO { + highp mat4 u_matrix; + highp float u_opacity; + lowp float props_pad1; + lowp float props_pad2; + lowp float props_pad3; +}; void main() { float t = texture(u_image, v_pos).r; diff --git a/shaders/heatmap_texture.vertex.glsl b/shaders/heatmap_texture.vertex.glsl index f0f89a1e5..714540473 100644 --- a/shaders/heatmap_texture.vertex.glsl +++ b/shaders/heatmap_texture.vertex.glsl @@ -1,10 +1,28 @@ -uniform mat4 u_matrix; -uniform vec2 u_world; layout (location = 0) in vec2 a_pos; out vec2 v_pos; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform HeatmapTexturePropsUBO { + highp mat4 u_matrix; + highp float u_opacity; + lowp float props_pad1; + lowp float props_pad2; + lowp float props_pad3; +}; + void main() { - gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); + gl_Position = u_matrix * vec4(a_pos * u_world_size, 0, 1); v_pos.x = a_pos.x; v_pos.y = 1.0 - a_pos.y; diff --git a/shaders/hillshade.fragment.glsl b/shaders/hillshade.fragment.glsl index f7b0f662d..499aa3c67 100644 --- a/shaders/hillshade.fragment.glsl +++ b/shaders/hillshade.fragment.glsl @@ -1,11 +1,16 @@ -uniform sampler2D u_image; in vec2 v_pos; +uniform sampler2D u_image; -uniform vec2 u_latrange; -uniform vec2 u_light; -uniform vec4 u_shadow; -uniform vec4 u_highlight; -uniform vec4 u_accent; +layout (std140) uniform HillshadeTilePropsUBO { + highp vec2 u_latrange; + highp vec2 u_light; +}; + +layout (std140) uniform HillshadeEvaluatedPropsUBO { + highp vec4 u_highlight; + highp vec4 u_shadow; + highp vec4 u_accent; +}; #define PI 3.141592653589793 diff --git a/shaders/hillshade.vertex.glsl b/shaders/hillshade.vertex.glsl index 0bac6fdff..acbc03803 100644 --- a/shaders/hillshade.vertex.glsl +++ b/shaders/hillshade.vertex.glsl @@ -1,8 +1,10 @@ -uniform mat4 u_matrix; - layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_texture_pos; +layout (std140) uniform HillshadeDrawableUBO { + highp mat4 u_matrix; +}; + out vec2 v_pos; void main() { diff --git a/shaders/hillshade_prepare.fragment.glsl b/shaders/hillshade_prepare.fragment.glsl index 3ef99c543..9f7988750 100644 --- a/shaders/hillshade_prepare.fragment.glsl +++ b/shaders/hillshade_prepare.fragment.glsl @@ -2,12 +2,15 @@ precision highp float; #endif -uniform sampler2D u_image; in vec2 v_pos; -uniform vec2 u_dimension; -uniform float u_zoom; -uniform float u_maxzoom; -uniform vec4 u_unpack; +uniform sampler2D u_image; + +layout (std140) uniform HillshadePrepareTilePropsUBO { + highp vec4 u_unpack; + highp vec2 u_dimension; + highp float u_zoom; + highp float u_maxzoom; +}; float getElevation(vec2 coord, float bias) { // Convert encoded elevation value to meters diff --git a/shaders/hillshade_prepare.vertex.glsl b/shaders/hillshade_prepare.vertex.glsl index aa8f8320f..b917e86fd 100644 --- a/shaders/hillshade_prepare.vertex.glsl +++ b/shaders/hillshade_prepare.vertex.glsl @@ -1,9 +1,17 @@ -uniform mat4 u_matrix; -uniform vec2 u_dimension; - layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_texture_pos; +layout (std140) uniform HillshadePrepareDrawableUBO { + highp mat4 u_matrix; +}; + +layout (std140) uniform HillshadePrepareTilePropsUBO { + highp vec4 u_unpack; + highp vec2 u_dimension; + highp float u_zoom; + highp float u_maxzoom; +}; + out vec2 v_pos; void main() { diff --git a/shaders/line.fragment.glsl b/shaders/line.fragment.glsl index 4ea11c11a..0d201bd28 100644 --- a/shaders/line.fragment.glsl +++ b/shaders/line.fragment.glsl @@ -1,4 +1,14 @@ -uniform lowp float u_device_pixel_ratio; +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; in vec2 v_width2; in vec2 v_normal; @@ -19,7 +29,7 @@ void main() { // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); fragColor = color * (alpha * opacity); diff --git a/shaders/line.vertex.glsl b/shaders/line.vertex.glsl index 65c99911d..5dc5f8726 100644 --- a/shaders/line.vertex.glsl +++ b/shaders/line.vertex.glsl @@ -9,10 +9,42 @@ layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform mediump float u_ratio; -uniform vec2 u_units_to_pixels; -uniform lowp float u_device_pixel_ratio; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform LineDrawableUBO { + highp mat4 u_matrix; + mediump float u_ratio; + // Interpolations + lowp float u_color_t; + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_gapwidth_t; + lowp float u_offset_t; + lowp float u_width_t; + lowp float drawable_pad1; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -36,7 +68,7 @@ void main() { // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; diff --git a/shaders/line_gradient.fragment.glsl b/shaders/line_gradient.fragment.glsl index d7e7504d6..a970705ab 100644 --- a/shaders/line_gradient.fragment.glsl +++ b/shaders/line_gradient.fragment.glsl @@ -1,4 +1,15 @@ -uniform lowp float u_device_pixel_ratio; +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; + uniform sampler2D u_image; in vec2 v_width2; @@ -19,7 +30,7 @@ void main() { // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); // For gradient lines, v_lineprogress is the ratio along the entire line, diff --git a/shaders/line_gradient.vertex.glsl b/shaders/line_gradient.vertex.glsl index b236f2883..f521a2270 100644 --- a/shaders/line_gradient.vertex.glsl +++ b/shaders/line_gradient.vertex.glsl @@ -13,10 +13,42 @@ layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform mediump float u_ratio; -uniform lowp float u_device_pixel_ratio; -uniform vec2 u_units_to_pixels; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform LineGradientDrawableUBO { + highp mat4 u_matrix; + mediump float u_ratio; + // Interpolations + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_gapwidth_t; + lowp float u_offset_t; + lowp float u_width_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -38,7 +70,7 @@ void main() { // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; diff --git a/shaders/line_pattern.fragment.glsl b/shaders/line_pattern.fragment.glsl index 10aff6031..4fbcf49ec 100644 --- a/shaders/line_pattern.fragment.glsl +++ b/shaders/line_pattern.fragment.glsl @@ -1,7 +1,23 @@ -uniform lowp float u_device_pixel_ratio; -uniform vec2 u_texsize; -uniform float u_fade; -uniform mediump vec4 u_scale; +layout (std140) uniform LinePatternTilePropsUBO { + lowp vec4 u_pattern_from; + lowp vec4 u_pattern_to; + mediump vec4 u_scale; + highp vec2 u_texsize; + highp float u_fade; + lowp float tileprops_pad1; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; uniform sampler2D u_image; @@ -10,14 +26,15 @@ in vec2 v_width2; in float v_linesofar; in float v_gamma_scale; -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to + #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity @@ -43,7 +60,7 @@ void main() { // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); float x_a = mod(v_linesofar / pattern_size_a.x, 1.0); diff --git a/shaders/line_pattern.vertex.glsl b/shaders/line_pattern.vertex.glsl index 60ad0c5b4..c42ab953d 100644 --- a/shaders/line_pattern.vertex.glsl +++ b/shaders/line_pattern.vertex.glsl @@ -13,10 +13,50 @@ layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform vec2 u_units_to_pixels; -uniform mediump float u_ratio; -uniform lowp float u_device_pixel_ratio; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; +layout (std140) uniform LinePatternDrawableUBO { + highp mat4 u_matrix; + mediump float u_ratio; + // Interpolations + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_offset_t; + lowp float u_gapwidth_t; + lowp float u_width_t; + lowp float u_pattern_from_t; + lowp float u_pattern_to_t; +}; + +layout (std140) uniform LinePatternTilePropsUBO { + lowp vec4 u_pattern_from; + lowp vec4 u_pattern_to; + mediump vec4 u_scale; + highp vec2 u_texsize; + highp float u_fade; + lowp float tileprops_pad1; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -28,8 +68,8 @@ out float v_gamma_scale; #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width -#pragma mapbox: define mediump vec4 pattern_from -#pragma mapbox: define mediump vec4 pattern_to +#pragma mapbox: define lowp vec4 pattern_from +#pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float blur @@ -42,7 +82,7 @@ void main() { // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; diff --git a/shaders/line_sdf.fragment.glsl b/shaders/line_sdf.fragment.glsl index 3cbd2c9b6..852f5f6d5 100644 --- a/shaders/line_sdf.fragment.glsl +++ b/shaders/line_sdf.fragment.glsl @@ -1,8 +1,23 @@ +layout (std140) uniform LineSDFTilePropsUBO { + highp float u_sdfgamma; + highp float u_mix; + lowp float tileprops_pad1; + lowp float tileprops_pad2; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; -uniform lowp float u_device_pixel_ratio; uniform sampler2D u_image; -uniform float u_sdfgamma; -uniform float u_mix; in vec2 v_normal; in vec2 v_width2; @@ -29,7 +44,7 @@ void main() { // Calculate the antialiasing fade factor. This is either when fading in // the line in case of an offset line (v_width2.t) or when fading out // (v_width2.s) - float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); float sdfdist_a = texture(u_image, v_tex_a).a; diff --git a/shaders/line_sdf.vertex.glsl b/shaders/line_sdf.vertex.glsl index 24397177b..434498972 100644 --- a/shaders/line_sdf.vertex.glsl +++ b/shaders/line_sdf.vertex.glsl @@ -13,14 +13,48 @@ layout (location = 0) in vec2 a_pos_normal; layout (location = 1) in vec4 a_data; -uniform mat4 u_matrix; -uniform mediump float u_ratio; -uniform lowp float u_device_pixel_ratio; -uniform vec2 u_patternscale_a; -uniform float u_tex_y_a; -uniform vec2 u_patternscale_b; -uniform float u_tex_y_b; -uniform vec2 u_units_to_pixels; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform LineSDFDrawableUBO { + highp mat4 u_matrix; + highp vec2 u_patternscale_a; + highp vec2 u_patternscale_b; + highp float u_tex_y_a; + highp float u_tex_y_b; + mediump float u_ratio; + // Interpolations + lowp float u_color_t; + lowp float u_blur_t; + lowp float u_opacity_t; + lowp float u_gapwidth_t; + lowp float u_offset_t; + lowp float u_width_t; + lowp float u_floorwidth_t; + lowp float drawable_pad1; + lowp float drawable_pad2; +}; + +layout (std140) uniform LineEvaluatedPropsUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + lowp float u_floorwidth; + lowp float props_pad1; + lowp float props_pad2; +}; out vec2 v_normal; out vec2 v_width2; @@ -47,7 +81,7 @@ void main() { // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. - float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0; vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; diff --git a/shaders/drawable.location_indicator.fragment.glsl b/shaders/location_indicator.fragment.glsl similarity index 100% rename from shaders/drawable.location_indicator.fragment.glsl rename to shaders/location_indicator.fragment.glsl diff --git a/shaders/drawable.location_indicator.vertex.glsl b/shaders/location_indicator.vertex.glsl similarity index 100% rename from shaders/drawable.location_indicator.vertex.glsl rename to shaders/location_indicator.vertex.glsl diff --git a/shaders/drawable.location_indicator_textured.fragment.glsl b/shaders/location_indicator_textured.fragment.glsl similarity index 100% rename from shaders/drawable.location_indicator_textured.fragment.glsl rename to shaders/location_indicator_textured.fragment.glsl diff --git a/shaders/drawable.location_indicator_textured.vertex.glsl b/shaders/location_indicator_textured.vertex.glsl similarity index 100% rename from shaders/drawable.location_indicator_textured.vertex.glsl rename to shaders/location_indicator_textured.vertex.glsl diff --git a/shaders/manifest.json b/shaders/manifest.json index 8d4345588..7a6e3d3f6 100644 --- a/shaders/manifest.json +++ b/shaders/manifest.json @@ -1,239 +1,10 @@ [ - { - "name": "BackgroundShader", - "header": "drawable_background", - "glsl_vert": "drawable.background.vertex.glsl", - "glsl_frag": "drawable.background.fragment.glsl", - "uses_ubos": true - }, - { - "name": "BackgroundPatternShader", - "header": "drawable_background_pattern", - "glsl_vert": "drawable.background_pattern.vertex.glsl", - "glsl_frag": "drawable.background_pattern.fragment.glsl", - "uses_ubos": true - }, - { - "name": "CircleShader", - "header": "drawable_circle", - "glsl_vert": "drawable.circle.vertex.glsl", - "glsl_frag": "drawable.circle.fragment.glsl", - "uses_ubos": true - }, - { - "name": "CollisionBoxShader", - "header": "drawable_collision_box", - "glsl_vert": "drawable.collision_box.vertex.glsl", - "glsl_frag": "drawable.collision_box.fragment.glsl", - "uses_ubos": true - }, - { - "name": "CollisionCircleShader", - "header": "drawable_collision_circle", - "glsl_vert": "drawable.collision_circle.vertex.glsl", - "glsl_frag": "drawable.collision_circle.fragment.glsl", - "uses_ubos": true - }, - { - "name": "CustomGeometryShader", - "header": "drawable_custom_geometry", - "glsl_vert": "drawable.custom_geometry.vertex.glsl", - "glsl_frag": "drawable.custom_geometry.fragment.glsl", - "uses_ubos": true - }, - { - "name": "CustomSymbolIconShader", - "header": "drawable_custom_symbol_icon", - "glsl_vert": "drawable.custom.symbol_icon.vertex.glsl", - "glsl_frag": "drawable.custom.symbol_icon.fragment.glsl", - "uses_ubos": true - }, - { - "name": "DebugShader", - "header": "drawable_debug", - "glsl_vert": "drawable.debug.vertex.glsl", - "glsl_frag": "drawable.debug.fragment.glsl", - "uses_ubos": true - }, - { - "name": "FillShader", - "header": "drawable_fill", - "glsl_vert": "drawable.fill.vertex.glsl", - "glsl_frag": "drawable.fill.fragment.glsl", - "uses_ubos": true - }, - { - "name": "FillOutlineShader", - "header": "drawable_fill_outline", - "glsl_vert": "drawable.fill_outline.vertex.glsl", - "glsl_frag": "drawable.fill_outline.fragment.glsl", - "uses_ubos": true - }, - { - "name": "FillPatternShader", - "header": "drawable_fill_pattern", - "glsl_vert": "drawable.fill_pattern.vertex.glsl", - "glsl_frag": "drawable.fill_pattern.fragment.glsl", - "uses_ubos": true - }, - { - "name": "FillOutlinePatternShader", - "header": "drawable_fill_outline_pattern", - "glsl_vert": "drawable.fill_outline_pattern.vertex.glsl", - "glsl_frag": "drawable.fill_outline_pattern.fragment.glsl", - "uses_ubos": true - }, - { - "name": "FillOutlineTriangulatedShader", - "header": "drawable_fill_outline_triangulated", - "glsl_vert": "drawable.fill_outline_triangulated.vertex.glsl", - "glsl_frag": "drawable.fill_outline_triangulated.fragment.glsl", - "uses_ubos": true - }, - { - "name": "FillExtrusionShader", - "header": "drawable_fill_extrusion", - "glsl_vert": "drawable.fill_extrusion.vertex.glsl", - "glsl_frag": "drawable.fill_extrusion.fragment.glsl", - "uses_ubos": true - }, - { - "name": "FillExtrusionPatternShader", - "header": "drawable_fill_extrusion_pattern", - "glsl_vert": "drawable.fill_extrusion_pattern.vertex.glsl", - "glsl_frag": "drawable.fill_extrusion_pattern.fragment.glsl", - "uses_ubos": true - }, - { - "name": "HeatmapShader", - "header": "drawable_heatmap", - "glsl_vert": "drawable.heatmap.vertex.glsl", - "glsl_frag": "drawable.heatmap.fragment.glsl", - "uses_ubos": true - }, - { - "name": "HeatmapTextureShader", - "header": "drawable_heatmap_texture", - "glsl_vert": "drawable.heatmap_texture.vertex.glsl", - "glsl_frag": "drawable.heatmap_texture.fragment.glsl", - "uses_ubos": true - }, - { - "name": "HillshadePrepareShader", - "header": "drawable_hillshade_prepare", - "glsl_vert": "drawable.hillshade_prepare.vertex.glsl", - "glsl_frag": "drawable.hillshade_prepare.fragment.glsl", - "uses_ubos": true - }, - { - "name": "HillshadeShader", - "header": "drawable_hillshade", - "glsl_vert": "drawable.hillshade.vertex.glsl", - "glsl_frag": "drawable.hillshade.fragment.glsl", - "uses_ubos": true - }, - { - "name": "LineShader", - "header": "drawable_line", - "glsl_vert": "drawable.line.vertex.glsl", - "glsl_frag": "drawable.line.fragment.glsl", - "uses_ubos": true - }, - { - "name": "LineGradientShader", - "header": "drawable_line_gradient", - "glsl_vert": "drawable.line_gradient.vertex.glsl", - "glsl_frag": "drawable.line_gradient.fragment.glsl", - "uses_ubos": true - }, - { - "name": "LinePatternShader", - "header": "drawable_line_pattern", - "glsl_vert": "drawable.line_pattern.vertex.glsl", - "glsl_frag": "drawable.line_pattern.fragment.glsl", - "uses_ubos": true - }, - { - "name": "LocationIndicatorShader", - "header": "drawable_location_indicator", - "glsl_vert": "drawable.location_indicator.vertex.glsl", - "glsl_frag": "drawable.location_indicator.fragment.glsl", - "uses_ubos": true - }, - { - "name": "LocationIndicatorTexturedShader", - "header": "drawable_location_indicator_textured", - "glsl_vert": "drawable.location_indicator_textured.vertex.glsl", - "glsl_frag": "drawable.location_indicator_textured.fragment.glsl", - "uses_ubos": true - }, - { - "name": "LineSDFShader", - "header": "drawable_line_sdf", - "glsl_vert": "drawable.line_sdf.vertex.glsl", - "glsl_frag": "drawable.line_sdf.fragment.glsl", - "uses_ubos": true - }, - { - "name": "RasterShader", - "header": "drawable_raster", - "glsl_vert": "drawable.raster.vertex.glsl", - "glsl_frag": "drawable.raster.fragment.glsl", - "uses_ubos": true - }, - { - "name": "SymbolIconShader", - "header": "drawable_symbol_icon", - "glsl_vert": "drawable.symbol_icon.vertex.glsl", - "glsl_frag": "drawable.symbol_icon.fragment.glsl", - "uses_ubos": true - }, - { - "name": "SymbolSDFIconShader", - "header": "drawable_symbol_sdf", - "glsl_vert": "drawable.symbol_sdf.vertex.glsl", - "glsl_frag": "drawable.symbol_sdf.fragment.glsl", - "uses_ubos": true - }, - { - "name": "SymbolTextAndIconShader", - "header": "drawable_symbol_text_and_icon", - "glsl_vert": "drawable.symbol_text_and_icon.vertex.glsl", - "glsl_frag": "drawable.symbol_text_and_icon.fragment.glsl", - "uses_ubos": true - }, - { - "name": "WideVectorShader", - "header": "drawable_wide_vector", - "glsl_vert": "_empty.glsl", - "glsl_frag": "_empty.glsl", - "uses_ubos": true - }, - { "name": "Prelude", "header": "prelude", "glsl_vert": "_prelude.vertex.glsl", "glsl_frag": "_prelude.fragment.glsl" }, - { - "name": "BackgroundProgram", - "header": "background", - "glsl_vert": "background.vertex.glsl", - "glsl_frag": "background.fragment.glsl" - }, - { - "name": "BackgroundPatternProgram", - "header": "background_pattern", - "glsl_vert": "background_pattern.vertex.glsl", - "glsl_frag": "background_pattern.fragment.glsl" - }, - { - "name": "CircleProgram", - "header": "circle", - "glsl_vert": "circle.vertex.glsl", - "glsl_frag": "circle.fragment.glsl" - }, { "name": "ClippingMaskProgram", "header": "clipping_mask", @@ -241,135 +12,213 @@ "glsl_frag": "clipping_mask.fragment.glsl" }, { - "name": "CollisionBoxProgram", + "name": "BackgroundShader", + "header": "background", + "glsl_vert": "background.vertex.glsl", + "glsl_frag": "background.fragment.glsl", + "uses_ubos": true + }, + { + "name": "BackgroundPatternShader", + "header": "background_pattern", + "glsl_vert": "background_pattern.vertex.glsl", + "glsl_frag": "background_pattern.fragment.glsl", + "uses_ubos": true + }, + { + "name": "CircleShader", + "header": "circle", + "glsl_vert": "circle.vertex.glsl", + "glsl_frag": "circle.fragment.glsl", + "uses_ubos": true + }, + { + "name": "CollisionBoxShader", "header": "collision_box", "glsl_vert": "collision_box.vertex.glsl", - "glsl_frag": "collision_box.fragment.glsl" + "glsl_frag": "collision_box.fragment.glsl", + "uses_ubos": true }, { - "name": "CollisionCircleProgram", + "name": "CollisionCircleShader", "header": "collision_circle", "glsl_vert": "collision_circle.vertex.glsl", - "glsl_frag": "collision_circle.fragment.glsl" + "glsl_frag": "collision_circle.fragment.glsl", + "uses_ubos": true }, { - "name": "DebugProgram", + "name": "CustomGeometryShader", + "header": "custom_geometry", + "glsl_vert": "custom_geometry.vertex.glsl", + "glsl_frag": "custom_geometry.fragment.glsl", + "uses_ubos": true + }, + { + "name": "CustomSymbolIconShader", + "header": "custom_symbol_icon", + "glsl_vert": "custom.symbol_icon.vertex.glsl", + "glsl_frag": "custom.symbol_icon.fragment.glsl", + "uses_ubos": true + }, + { + "name": "DebugShader", "header": "debug", "glsl_vert": "debug.vertex.glsl", - "glsl_frag": "debug.fragment.glsl" + "glsl_frag": "debug.fragment.glsl", + "uses_ubos": true }, { - "name": "FillExtrusionPatternProgram", - "header": "fill_extrusion_pattern", - "glsl_vert": "fill_extrusion_pattern.vertex.glsl", - "glsl_frag": "fill_extrusion_pattern.fragment.glsl" - }, - { - "name": "FillExtrusionProgram", - "header": "fill_extrusion", - "glsl_vert": "fill_extrusion.vertex.glsl", - "glsl_frag": "fill_extrusion.fragment.glsl" - }, - { - "name": "FillOutlinePatternProgram", - "header": "fill_outline_pattern", - "glsl_vert": "fill_outline_pattern.vertex.glsl", - "glsl_frag": "fill_outline_pattern.fragment.glsl" - }, - { - "name": "FillOutlineProgram", - "header": "fill_outline", - "glsl_vert": "fill_outline.vertex.glsl", - "glsl_frag": "fill_outline.fragment.glsl" - }, - { - "name": "FillPatternProgram", - "header": "fill_pattern", - "glsl_vert": "fill_pattern.vertex.glsl", - "glsl_frag": "fill_pattern.fragment.glsl" - }, - { - "name": "FillProgram", + "name": "FillShader", "header": "fill", "glsl_vert": "fill.vertex.glsl", - "glsl_frag": "fill.fragment.glsl" + "glsl_frag": "fill.fragment.glsl", + "uses_ubos": true }, { - "name": "HeatmapTextureProgram", - "header": "heatmap_texture", - "glsl_vert": "heatmap_texture.vertex.glsl", - "glsl_frag": "heatmap_texture.fragment.glsl" + "name": "FillOutlineShader", + "header": "fill_outline", + "glsl_vert": "fill_outline.vertex.glsl", + "glsl_frag": "fill_outline.fragment.glsl", + "uses_ubos": true }, { - "name": "HeatmapProgram", + "name": "FillPatternShader", + "header": "fill_pattern", + "glsl_vert": "fill_pattern.vertex.glsl", + "glsl_frag": "fill_pattern.fragment.glsl", + "uses_ubos": true + }, + { + "name": "FillOutlinePatternShader", + "header": "fill_outline_pattern", + "glsl_vert": "fill_outline_pattern.vertex.glsl", + "glsl_frag": "fill_outline_pattern.fragment.glsl", + "uses_ubos": true + }, + { + "name": "FillOutlineTriangulatedShader", + "header": "fill_outline_triangulated", + "glsl_vert": "fill_outline_triangulated.vertex.glsl", + "glsl_frag": "fill_outline_triangulated.fragment.glsl", + "uses_ubos": true + }, + { + "name": "FillExtrusionShader", + "header": "fill_extrusion", + "glsl_vert": "fill_extrusion.vertex.glsl", + "glsl_frag": "fill_extrusion.fragment.glsl", + "uses_ubos": true + }, + { + "name": "FillExtrusionPatternShader", + "header": "fill_extrusion_pattern", + "glsl_vert": "fill_extrusion_pattern.vertex.glsl", + "glsl_frag": "fill_extrusion_pattern.fragment.glsl", + "uses_ubos": true + }, + { + "name": "HeatmapShader", "header": "heatmap", "glsl_vert": "heatmap.vertex.glsl", - "glsl_frag": "heatmap.fragment.glsl" + "glsl_frag": "heatmap.fragment.glsl", + "uses_ubos": true }, { - "name": "HillshadePrepareProgram", + "name": "HeatmapTextureShader", + "header": "heatmap_texture", + "glsl_vert": "heatmap_texture.vertex.glsl", + "glsl_frag": "heatmap_texture.fragment.glsl", + "uses_ubos": true + }, + { + "name": "HillshadePrepareShader", "header": "hillshade_prepare", "glsl_vert": "hillshade_prepare.vertex.glsl", - "glsl_frag": "hillshade_prepare.fragment.glsl" + "glsl_frag": "hillshade_prepare.fragment.glsl", + "uses_ubos": true }, { - "name": "HillshadeProgram", + "name": "HillshadeShader", "header": "hillshade", "glsl_vert": "hillshade.vertex.glsl", - "glsl_frag": "hillshade.fragment.glsl" + "glsl_frag": "hillshade.fragment.glsl", + "uses_ubos": true }, { - "name": "LineGradientProgram", - "header": "line_gradient", - "glsl_vert": "line_gradient.vertex.glsl", - "glsl_frag": "line_gradient.fragment.glsl" - }, - { - "name": "LinePatternProgram", - "header": "line_pattern", - "glsl_vert": "line_pattern.vertex.glsl", - "glsl_frag": "line_pattern.fragment.glsl" - }, - { - "name": "LineSDFProgram", - "header": "line_sdf", - "glsl_vert": "line_sdf.vertex.glsl", - "glsl_frag": "line_sdf.fragment.glsl" - }, - { - "name": "LineProgram", + "name": "LineShader", "header": "line", "glsl_vert": "line.vertex.glsl", - "glsl_frag": "line.fragment.glsl" + "glsl_frag": "line.fragment.glsl", + "uses_ubos": true }, { - "name": "RasterProgram", + "name": "LineGradientShader", + "header": "line_gradient", + "glsl_vert": "line_gradient.vertex.glsl", + "glsl_frag": "line_gradient.fragment.glsl", + "uses_ubos": true + }, + { + "name": "LinePatternShader", + "header": "line_pattern", + "glsl_vert": "line_pattern.vertex.glsl", + "glsl_frag": "line_pattern.fragment.glsl", + "uses_ubos": true + }, + { + "name": "LocationIndicatorShader", + "header": "location_indicator", + "glsl_vert": "location_indicator.vertex.glsl", + "glsl_frag": "location_indicator.fragment.glsl", + "uses_ubos": true + }, + { + "name": "LocationIndicatorTexturedShader", + "header": "location_indicator_textured", + "glsl_vert": "location_indicator_textured.vertex.glsl", + "glsl_frag": "location_indicator_textured.fragment.glsl", + "uses_ubos": true + }, + { + "name": "LineSDFShader", + "header": "line_sdf", + "glsl_vert": "line_sdf.vertex.glsl", + "glsl_frag": "line_sdf.fragment.glsl", + "uses_ubos": true + }, + { + "name": "RasterShader", "header": "raster", "glsl_vert": "raster.vertex.glsl", - "glsl_frag": "raster.fragment.glsl" + "glsl_frag": "raster.fragment.glsl", + "uses_ubos": true }, { - "name": "SymbolIconProgram", + "name": "SymbolIconShader", "header": "symbol_icon", "glsl_vert": "symbol_icon.vertex.glsl", - "glsl_frag": "symbol_icon.fragment.glsl" + "glsl_frag": "symbol_icon.fragment.glsl", + "uses_ubos": true }, { - "name": "SymbolSDFTextProgram", - "header": "symbol_sdf_text", + "name": "SymbolSDFIconShader", + "header": "symbol_sdf", "glsl_vert": "symbol_sdf.vertex.glsl", - "glsl_frag": "symbol_sdf.fragment.glsl" + "glsl_frag": "symbol_sdf.fragment.glsl", + "uses_ubos": true }, { - "name": "SymbolSDFIconProgram", - "header": "symbol_sdf_icon", - "glsl_vert": "symbol_sdf.vertex.glsl", - "glsl_frag": "symbol_sdf.fragment.glsl" - }, - { - "name": "SymbolTextAndIconProgram", + "name": "SymbolTextAndIconShader", "header": "symbol_text_and_icon", "glsl_vert": "symbol_text_and_icon.vertex.glsl", - "glsl_frag": "symbol_text_and_icon.fragment.glsl" + "glsl_frag": "symbol_text_and_icon.fragment.glsl", + "uses_ubos": true + }, + { + "name": "WideVectorShader", + "header": "wide_vector", + "glsl_vert": "_empty.glsl", + "glsl_frag": "_empty.glsl", + "uses_ubos": true } ] diff --git a/shaders/raster.fragment.glsl b/shaders/raster.fragment.glsl index 473d45ddc..352cf5a00 100644 --- a/shaders/raster.fragment.glsl +++ b/shaders/raster.fragment.glsl @@ -1,17 +1,23 @@ -uniform float u_fade_t; -uniform float u_opacity; +layout (std140) uniform RasterEvaluatedPropsUBO { + highp vec3 u_spin_weights; + highp vec2 u_tl_parent; + highp float u_scale_parent; + highp float u_buffer_scale; + highp float u_fade_t; + highp float u_opacity; + highp float u_brightness_low; + highp float u_brightness_high; + highp float u_saturation_factor; + highp float u_contrast_factor; + lowp float props_pad1; + lowp float props_pad2; +}; uniform sampler2D u_image0; uniform sampler2D u_image1; + in vec2 v_pos0; in vec2 v_pos1; -uniform float u_brightness_low; -uniform float u_brightness_high; - -uniform float u_saturation_factor; -uniform float u_contrast_factor; -uniform vec3 u_spin_weights; - void main() { // read and cross-fade colors from the main and parent tiles diff --git a/shaders/raster.vertex.glsl b/shaders/raster.vertex.glsl index b3a764e74..331f376fe 100644 --- a/shaders/raster.vertex.glsl +++ b/shaders/raster.vertex.glsl @@ -1,7 +1,20 @@ -uniform mat4 u_matrix; -uniform vec2 u_tl_parent; -uniform float u_scale_parent; -uniform float u_buffer_scale; +layout (std140) uniform RasterDrawableUBO { + highp mat4 u_matrix; +}; +layout (std140) uniform RasterEvaluatedPropsUBO { + highp vec3 u_spin_weights; + highp vec2 u_tl_parent; + highp float u_scale_parent; + highp float u_buffer_scale; + highp float u_fade_t; + highp float u_opacity; + highp float u_brightness_low; + highp float u_brightness_high; + highp float u_saturation_factor; + highp float u_contrast_factor; + lowp float props_pad1; + lowp float props_pad2; +}; layout (location = 0) in vec2 a_pos; layout (location = 1) in vec2 a_texture_pos; diff --git a/shaders/symbol_icon.fragment.glsl b/shaders/symbol_icon.fragment.glsl index ec81b9363..ce3a301d5 100644 --- a/shaders/symbol_icon.fragment.glsl +++ b/shaders/symbol_icon.fragment.glsl @@ -1,11 +1,35 @@ uniform sampler2D u_texture; +layout (std140) uniform SymbolTilePropsUBO { + bool u_is_text; + bool u_is_halo; + highp float u_gamma_scale; + lowp float tileprops_pad1; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; + in vec2 v_tex; in float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { + highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; + #pragma mapbox: initialize lowp float opacity lowp float alpha = opacity * v_fade_opacity; diff --git a/shaders/symbol_icon.vertex.glsl b/shaders/symbol_icon.vertex.glsl index 221423195..678f3323b 100644 --- a/shaders/symbol_icon.vertex.glsl +++ b/shaders/symbol_icon.vertex.glsl @@ -4,24 +4,57 @@ layout (location = 2) in vec4 a_pixeloffset; layout (location = 3) in vec3 a_projected_pos; layout (location = 4) in float a_fade_opacity; -uniform bool u_is_size_zoom_constant; -uniform bool u_is_size_feature_constant; -uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function -uniform highp float u_size; // used when size is both zoom and feature constant -uniform highp float u_camera_to_center_distance; -uniform highp float u_pitch; -uniform bool u_rotate_symbol; -uniform highp float u_aspect_ratio; -uniform float u_fade_change; +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; -uniform mat4 u_matrix; -uniform mat4 u_label_plane_matrix; -uniform mat4 u_coord_matrix; +layout (std140) uniform SymbolDrawableUBO { + highp mat4 u_matrix; + highp mat4 u_label_plane_matrix; + highp mat4 u_coord_matrix; -uniform bool u_is_text; -uniform bool u_pitch_with_map; + highp vec2 u_texsize; + highp vec2 u_texsize_icon; -uniform vec2 u_texsize; + bool u_is_text_prop; + bool u_rotate_symbol; + bool u_pitch_with_map; + bool u_is_size_zoom_constant; + bool u_is_size_feature_constant; + + highp float u_size_t; // used to interpolate between zoom stops when size is a composite function + highp float u_size; // used when size is both zoom and feature constant + + // Interpolations + highp float u_fill_color_t; + highp float u_halo_color_t; + highp float u_opacity_t; + highp float u_halo_width_t; + highp float u_halo_blur_t; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; out vec2 v_tex; out float v_fade_opacity; @@ -29,6 +62,8 @@ out float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { + highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; + #pragma mapbox: initialize lowp float opacity vec2 a_pos = a_pos_offset.xy; @@ -65,7 +100,7 @@ void main() { size *= perspective_ratio; - float fontScale = u_is_text ? size / 24.0 : size; + float fontScale = u_is_text_prop ? size / 24.0 : size; highp float symbol_rotation = 0.0; if (u_rotate_symbol) { @@ -87,6 +122,6 @@ void main() { v_tex = a_tex / u_texsize; vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); } diff --git a/shaders/symbol_sdf.fragment.glsl b/shaders/symbol_sdf.fragment.glsl index 59cf59c1c..6bc97ac3e 100644 --- a/shaders/symbol_sdf.fragment.glsl +++ b/shaders/symbol_sdf.fragment.glsl @@ -1,10 +1,28 @@ #define SDF_PX 8.0 -uniform bool u_is_halo; +layout (std140) uniform SymbolTilePropsUBO { + bool u_is_text; + bool u_is_halo; + highp float u_gamma_scale; + lowp float tileprops_pad1; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; + uniform sampler2D u_texture; -uniform highp float u_gamma_scale; -uniform lowp float u_device_pixel_ratio; -uniform bool u_is_text; in vec2 v_data0; in vec3 v_data1; @@ -16,13 +34,19 @@ in vec3 v_data1; #pragma mapbox: define lowp float halo_blur void main() { + highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color; + highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color; + highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; + highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width; + highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur; + #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur - float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; + float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO; vec2 tex = v_data0.xy; float gamma_scale = v_data1.x; diff --git a/shaders/symbol_sdf.vertex.glsl b/shaders/symbol_sdf.vertex.glsl index 2141399de..6c94980d7 100644 --- a/shaders/symbol_sdf.vertex.glsl +++ b/shaders/symbol_sdf.vertex.glsl @@ -11,21 +11,58 @@ layout (location = 4) in float a_fade_opacity; // For composite functions: // [ text-size(lowerZoomStop, feature), // text-size(upperZoomStop, feature) ] -uniform bool u_is_size_zoom_constant; -uniform bool u_is_size_feature_constant; -uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function -uniform highp float u_size; // used when size is both zoom and feature constant -uniform mat4 u_matrix; -uniform mat4 u_label_plane_matrix; -uniform mat4 u_coord_matrix; -uniform bool u_is_text; -uniform bool u_pitch_with_map; -uniform highp float u_pitch; -uniform bool u_rotate_symbol; -uniform highp float u_aspect_ratio; -uniform highp float u_camera_to_center_distance; -uniform float u_fade_change; -uniform vec2 u_texsize; + +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform SymbolDrawableUBO { + highp mat4 u_matrix; + highp mat4 u_label_plane_matrix; + highp mat4 u_coord_matrix; + + highp vec2 u_texsize; + highp vec2 u_texsize_icon; + + bool u_is_text_prop; + bool u_rotate_symbol; + bool u_pitch_with_map; + bool u_is_size_zoom_constant; + bool u_is_size_feature_constant; + + highp float u_size_t; // used to interpolate between zoom stops when size is a composite function + highp float u_size; // used when size is both zoom and feature constant + + // Interpolations + highp float u_fill_color_t; + highp float u_halo_color_t; + highp float u_opacity_t; + highp float u_halo_width_t; + highp float u_halo_blur_t; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; out vec2 v_data0; out vec3 v_data1; @@ -37,6 +74,12 @@ out vec3 v_data1; #pragma mapbox: define lowp float halo_blur void main() { + highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color; + highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color; + highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; + highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width; + highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur; + #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity @@ -81,7 +124,7 @@ void main() { size *= perspective_ratio; - float fontScale = u_is_text ? size / 24.0 : size; + float fontScale = u_is_text_prop ? size / 24.0 : size; highp float symbol_rotation = 0.0; if (u_rotate_symbol) { @@ -105,7 +148,7 @@ void main() { float gamma_scale = gl_Position.w; vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); v_data0 = a_tex / u_texsize; diff --git a/shaders/symbol_text_and_icon.fragment.glsl b/shaders/symbol_text_and_icon.fragment.glsl index 672e1dcb1..8c307d0f0 100644 --- a/shaders/symbol_text_and_icon.fragment.glsl +++ b/shaders/symbol_text_and_icon.fragment.glsl @@ -3,11 +3,30 @@ #define SDF 1.0 #define ICON 0.0 -uniform bool u_is_halo; +layout (std140) uniform SymbolTilePropsUBO { + bool u_is_text; + bool u_is_halo; + highp float u_gamma_scale; + lowp float tileprops_pad1; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; + uniform sampler2D u_texture; uniform sampler2D u_texture_icon; -uniform highp float u_gamma_scale; -uniform lowp float u_device_pixel_ratio; in vec4 v_data0; in vec4 v_data1; @@ -19,6 +38,12 @@ in vec4 v_data1; #pragma mapbox: define lowp float halo_blur void main() { + highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color; + highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color; + highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity; + highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width; + highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur; + #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity @@ -40,7 +65,7 @@ void main() { vec2 tex = v_data0.xy; - float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; + float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO; float gamma_scale = v_data1.x; float size = v_data1.y; diff --git a/shaders/symbol_text_and_icon.vertex.glsl b/shaders/symbol_text_and_icon.vertex.glsl index f4812aacc..6035d4512 100644 --- a/shaders/symbol_text_and_icon.vertex.glsl +++ b/shaders/symbol_text_and_icon.vertex.glsl @@ -10,22 +10,58 @@ layout (location = 3) in float a_fade_opacity; // For composite functions: // [ text-size(lowerZoomStop, feature), // text-size(upperZoomStop, feature) ] -uniform bool u_is_size_zoom_constant; -uniform bool u_is_size_feature_constant; -uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function -uniform highp float u_size; // used when size is both zoom and feature constant -uniform mat4 u_matrix; -uniform mat4 u_label_plane_matrix; -uniform mat4 u_coord_matrix; -uniform bool u_is_text; -uniform bool u_pitch_with_map; -uniform highp float u_pitch; -uniform bool u_rotate_symbol; -uniform highp float u_aspect_ratio; -uniform highp float u_camera_to_center_distance; -uniform float u_fade_change; -uniform vec2 u_texsize; -uniform vec2 u_texsize_icon; + +layout (std140) uniform GlobalPaintParamsUBO { + highp vec2 u_pattern_atlas_texsize; + highp vec2 u_units_to_pixels; + highp vec2 u_world_size; + highp float u_camera_to_center_distance; + highp float u_symbol_fade_change; + highp float u_aspect_ratio; + highp float u_pixel_ratio; + highp float u_map_zoom; + lowp float global_pad1; +}; + +layout (std140) uniform SymbolDrawableUBO { + highp mat4 u_matrix; + highp mat4 u_label_plane_matrix; + highp mat4 u_coord_matrix; + + highp vec2 u_texsize; + highp vec2 u_texsize_icon; + + bool u_is_text_prop; + bool u_rotate_symbol; + bool u_pitch_with_map; + bool u_is_size_zoom_constant; + bool u_is_size_feature_constant; + + highp float u_size_t; // used to interpolate between zoom stops when size is a composite function + highp float u_size; // used when size is both zoom and feature constant + + // Interpolations + highp float u_fill_color_t; + highp float u_halo_color_t; + highp float u_opacity_t; + highp float u_halo_width_t; + highp float u_halo_blur_t; +}; + +layout (std140) uniform SymbolEvaluatedPropsUBO { + highp vec4 u_text_fill_color; + highp vec4 u_text_halo_color; + highp float u_text_opacity; + highp float u_text_halo_width; + highp float u_text_halo_blur; + lowp float props_pad1; + highp vec4 u_icon_fill_color; + highp vec4 u_icon_halo_color; + highp float u_icon_opacity; + highp float u_icon_halo_width; + highp float u_icon_halo_blur; + lowp float props_pad2; +}; out vec4 v_data0; out vec4 v_data1; @@ -37,6 +73,12 @@ out vec4 v_data1; #pragma mapbox: define lowp float halo_blur void main() { + highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color; + highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color; + highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity; + highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width; + highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur; + #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity @@ -105,7 +147,7 @@ void main() { float gamma_scale = gl_Position.w; vec2 fade_opacity = unpack_opacity(a_fade_opacity); - float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; + float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change; float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); v_data0.xy = a_tex / u_texsize; diff --git a/src/mbgl/gfx/drawable_builder_impl.cpp b/src/mbgl/gfx/drawable_builder_impl.cpp index 781a0a857..98c54f74a 100644 --- a/src/mbgl/gfx/drawable_builder_impl.cpp +++ b/src/mbgl/gfx/drawable_builder_impl.cpp @@ -203,8 +203,8 @@ void DrawableBuilder::Impl::setupForWideVectors(gfx::Context& context, gfx::Draw } // segments - SegmentVector triangleSegments; - triangleSegments.emplace_back(Segment{0, 0, 12, 18}); + SegmentVector triangleSegments; + triangleSegments.emplace_back(0, 0, 12, 18); // add to builder { diff --git a/src/mbgl/gfx/fill_generator.cpp b/src/mbgl/gfx/fill_generator.cpp index f1879fdcd..4e5f61f3b 100644 --- a/src/mbgl/gfx/fill_generator.cpp +++ b/src/mbgl/gfx/fill_generator.cpp @@ -38,7 +38,7 @@ namespace { std::size_t addRingVertices(gfx::VertexVector& vertices, const GeometryCoordinates& ring) { for (auto& point : ring) { - vertices.emplace_back(FillProgram::layoutVertex(point)); + vertices.emplace_back(FillBucket::layoutVertex(point)); } return ring.size(); } @@ -52,7 +52,7 @@ std::size_t totalVerticesCheck(const GeometryCollection& polygon) { return totalVertices; } -void addFillIndices(SegmentVector& fillSegments, +void addFillIndices(SegmentVector& fillSegments, gfx::IndexVector& fillIndexes, std::vector& indices, std::size_t startVertices, @@ -80,7 +80,7 @@ void addFillIndices(SegmentVector& fillSegments, void addOutlineIndices(std::size_t base, std::size_t nVertices, - SegmentVector& lineSegments, + SegmentVector& lineSegments, gfx::IndexVector& lineIndexes) { if (nVertices == 0) return; @@ -106,7 +106,7 @@ void addOutlineIndices(std::size_t base, void generateFillBuffers(const GeometryCollection& geometry, gfx::VertexVector& fillVertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments) { + SegmentVector& fillSegments) { for (auto& polygon : classifyRings(geometry)) { // Optimize polygons with many interior rings for earcut tesselation. limitHoles(polygon, 500); @@ -126,9 +126,9 @@ void generateFillBuffers(const GeometryCollection& geometry, void generateFillAndOutineBuffers(const GeometryCollection& geometry, gfx::VertexVector& vertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments, + SegmentVector& fillSegments, gfx::IndexVector& lineIndexes, - SegmentVector& lineSegments) { + SegmentVector& lineSegments) { for (auto& polygon : classifyRings(geometry)) { // Optimize polygons with many interior rings for earcut tesselation. limitHoles(polygon, 500); @@ -150,18 +150,18 @@ void generateFillAndOutineBuffers(const GeometryCollection& geometry, void generateFillAndOutineBuffers(const GeometryCollection& geometry, gfx::VertexVector& fillVertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments, + SegmentVector& fillSegments, gfx::VertexVector& lineVertices, gfx::IndexVector& lineIndexes, - SegmentVector& lineSegments) { - gfx::PolylineGenerator> lineGenerator( + SegmentVector& lineSegments) { + gfx::PolylineGenerator lineGenerator( lineVertices, - LineProgram::layoutVertex, + LineBucket::layoutVertex, lineSegments, - [](std::size_t vertexOffset, std::size_t indexOffset) -> Segment { - return Segment(vertexOffset, indexOffset); + [](std::size_t vertexOffset, std::size_t indexOffset) -> SegmentBase { + return SegmentBase(vertexOffset, indexOffset); }, - [](auto& seg) -> Segment& { return seg; }, + [](auto& seg) -> SegmentBase& { return seg; }, lineIndexes); gfx::PolylineGeneratorOptions lineOptions; @@ -187,20 +187,20 @@ void generateFillAndOutineBuffers(const GeometryCollection& geometry, void generateFillAndOutineBuffers(const GeometryCollection& geometry, gfx::VertexVector& fillVertices, gfx::IndexVector& fillIndexes, - SegmentVector& fillSegments, + SegmentVector& fillSegments, gfx::VertexVector& lineVertices, gfx::IndexVector& lineIndexes, - SegmentVector& lineSegments, + SegmentVector& lineSegments, gfx::IndexVector& basicLineIndexes, - SegmentVector& basicLineSegments) { - gfx::PolylineGenerator> lineGenerator( + SegmentVector& basicLineSegments) { + gfx::PolylineGenerator lineGenerator( lineVertices, - LineProgram::layoutVertex, + LineBucket::layoutVertex, lineSegments, - [](std::size_t vertexOffset, std::size_t indexOffset) -> Segment { - return Segment(vertexOffset, indexOffset); + [](std::size_t vertexOffset, std::size_t indexOffset) -> SegmentBase { + return SegmentBase(vertexOffset, indexOffset); }, - [](auto& seg) -> Segment& { return seg; }, + [](auto& seg) -> SegmentBase& { return seg; }, lineIndexes); gfx::PolylineGeneratorOptions lineOptions; diff --git a/src/mbgl/gfx/polyline_generator.cpp b/src/mbgl/gfx/polyline_generator.cpp index fc4cb1ccd..897c378bc 100644 --- a/src/mbgl/gfx/polyline_generator.cpp +++ b/src/mbgl/gfx/polyline_generator.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -637,7 +637,7 @@ void PolylineGenerator::addPieSliceVertex(const GeometryCoordinate& cur template class PolylineGenerator>; -template class PolylineGenerator>; +template class PolylineGenerator; } // namespace gfx } // namespace mbgl diff --git a/src/mbgl/layout/circle_layout.hpp b/src/mbgl/layout/circle_layout.hpp index 72a870fce..e5197565b 100644 --- a/src/mbgl/layout/circle_layout.hpp +++ b/src/mbgl/layout/circle_layout.hpp @@ -126,10 +126,10 @@ private: // │ 1 2 │ // └─────────┘ // - vertices.emplace_back(CircleProgram::vertex(point, -1, -1)); // 1 - vertices.emplace_back(CircleProgram::vertex(point, 1, -1)); // 2 - vertices.emplace_back(CircleProgram::vertex(point, 1, 1)); // 3 - vertices.emplace_back(CircleProgram::vertex(point, -1, 1)); // 4 + vertices.emplace_back(CircleBucket::vertex(point, -1, -1)); // 1 + vertices.emplace_back(CircleBucket::vertex(point, 1, -1)); // 2 + vertices.emplace_back(CircleBucket::vertex(point, 1, 1)); // 3 + vertices.emplace_back(CircleBucket::vertex(point, -1, 1)); // 4 auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 4b265a482..50a80c8b9 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -1087,53 +1087,53 @@ size_t SymbolLayout::addSymbol(SymbolBucket::Buffer& buffer, // coordinates (2 triangles) auto& vertices = buffer.vertices(); - vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point, - tl, - symbol.glyphOffset.y, - tex.x, - tex.y, - sizeData, - symbol.isSDF, - pixelOffsetTL, - minFontScale)); - vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point, - tr, - symbol.glyphOffset.y, - tex.x + tex.w, - tex.y, - sizeData, - symbol.isSDF, - {pixelOffsetBR.x, pixelOffsetTL.y}, - minFontScale)); - vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point, - bl, - symbol.glyphOffset.y, - tex.x, - tex.y + tex.h, - sizeData, - symbol.isSDF, - {pixelOffsetTL.x, pixelOffsetBR.y}, - minFontScale)); - vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point, - br, - symbol.glyphOffset.y, - tex.x + tex.w, - tex.y + tex.h, - sizeData, - symbol.isSDF, - pixelOffsetBR, - minFontScale)); + vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point, + tl, + symbol.glyphOffset.y, + tex.x, + tex.y, + sizeData, + symbol.isSDF, + pixelOffsetTL, + minFontScale)); + vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point, + tr, + symbol.glyphOffset.y, + tex.x + tex.w, + tex.y, + sizeData, + symbol.isSDF, + {pixelOffsetBR.x, pixelOffsetTL.y}, + minFontScale)); + vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point, + bl, + symbol.glyphOffset.y, + tex.x, + tex.y + tex.h, + sizeData, + symbol.isSDF, + {pixelOffsetTL.x, pixelOffsetBR.y}, + minFontScale)); + vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point, + br, + symbol.glyphOffset.y, + tex.x + tex.w, + tex.y + tex.h, + sizeData, + symbol.isSDF, + pixelOffsetBR, + minFontScale)); // Dynamic/Opacity vertices are initialized so that the vertex count always // agrees with the layout vertex buffer, but they will always be updated // before rendering happens - auto dynamicVertex = SymbolSDFIconProgram::dynamicLayoutVertex(labelAnchor.point, 0); + auto dynamicVertex = SymbolBucket::dynamicLayoutVertex(labelAnchor.point, 0); buffer.dynamicVertices().emplace_back(dynamicVertex); buffer.dynamicVertices().emplace_back(dynamicVertex); buffer.dynamicVertices().emplace_back(dynamicVertex); buffer.dynamicVertices().emplace_back(dynamicVertex); - auto opacityVertex = SymbolSDFIconProgram::opacityVertex(true, 1.0); + auto opacityVertex = SymbolBucket::opacityVertex(true, 1.0); buffer.opacityVertices().emplace_back(opacityVertex); buffer.opacityVertices().emplace_back(opacityVertex); buffer.opacityVertices().emplace_back(opacityVertex); @@ -1209,18 +1209,18 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) { auto index = static_cast(segment.vertexLength); collisionBuffer.vertices().emplace_back( - CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, tl)); + SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, tl)); collisionBuffer.vertices().emplace_back( - CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, tr)); + SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, tr)); collisionBuffer.vertices().emplace_back( - CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, br)); + SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, br)); collisionBuffer.vertices().emplace_back( - CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, bl)); + SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, bl)); // Dynamic vertices are initialized so that the vertex count // always agrees with the layout vertex buffer, but they will // always be updated before rendering happens - auto dynamicVertex = CollisionBoxProgram::dynamicVertex(false, false, {}); + auto dynamicVertex = SymbolBucket::collisionDynamicVertex(false, false, {}); collisionBuffer.dynamicVertices().emplace_back(dynamicVertex); collisionBuffer.dynamicVertices().emplace_back(dynamicVertex); collisionBuffer.dynamicVertices().emplace_back(dynamicVertex); diff --git a/src/mbgl/layout/symbol_projection.cpp b/src/mbgl/layout/symbol_projection.cpp index 57052a0b0..a6d14600b 100644 --- a/src/mbgl/layout/symbol_projection.cpp +++ b/src/mbgl/layout/symbol_projection.cpp @@ -141,7 +141,7 @@ bool isVisible(const vec4& anchorPos, const std::array& clippingBuffe void addDynamicAttributes(const Point& anchorPoint, const float angle, gfx::VertexVector>& dynamicVertexArray) { - auto dynamicVertex = SymbolSDFIconProgram::dynamicLayoutVertex(anchorPoint, angle); + auto dynamicVertex = SymbolBucket::dynamicLayoutVertex(anchorPoint, angle); dynamicVertexArray.emplace_back(dynamicVertex); dynamicVertexArray.emplace_back(dynamicVertex); dynamicVertexArray.emplace_back(dynamicVertex); diff --git a/src/mbgl/layout/symbol_projection.hpp b/src/mbgl/layout/symbol_projection.hpp index 6cfade3da..903b32c28 100644 --- a/src/mbgl/layout/symbol_projection.hpp +++ b/src/mbgl/layout/symbol_projection.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include namespace mbgl { diff --git a/src/mbgl/programs/background_pattern_program.hpp b/src/mbgl/programs/background_pattern_program.hpp deleted file mode 100644 index 4b6606567..000000000 --- a/src/mbgl/programs/background_pattern_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/background_program.cpp b/src/mbgl/programs/background_program.cpp deleted file mode 100644 index 46fb13db3..000000000 --- a/src/mbgl/programs/background_program.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include -#include - -namespace mbgl { - -using namespace style; - -static_assert(sizeof(BackgroundLayoutVertex) == 4, "expected BackgroundLayoutVertex size"); - -BackgroundPatternProgram::LayoutUniformValues BackgroundPatternProgram::layoutUniformValues( - mat4 matrix, - float opacity, - Size atlasSize, - const ImagePosition& a, - const ImagePosition& b, - const CrossfadeParameters& fading, - const UnwrappedTileID& tileID, - const TransformState& state) { - int32_t tileSizeAtNearestZoom = static_cast(util::tileSize_D * - state.zoomScale(state.getIntegerZoom() - tileID.canonical.z)); - int32_t pixelX = static_cast(tileSizeAtNearestZoom * - (tileID.canonical.x + tileID.wrap * state.zoomScale(tileID.canonical.z))); - int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y; - - return { - uniforms::matrix::Value(matrix), - uniforms::opacity::Value(opacity), - uniforms::texsize::Value(atlasSize), - uniforms::pattern_tl_a::Value(a.tl()), - uniforms::pattern_br_a::Value(a.br()), - uniforms::pattern_tl_b::Value(b.tl()), - uniforms::pattern_br_b::Value(b.br()), - uniforms::pattern_size_a::Value(a.displaySize()), - uniforms::pattern_size_b::Value(b.displaySize()), - uniforms::scale_a::Value(fading.fromScale), - uniforms::scale_b::Value(fading.toScale), - uniforms::mix::Value(fading.t), - uniforms::pixel_coord_upper::Value( - std::array{{static_cast(pixelX >> 16), static_cast(pixelY >> 16)}}), - uniforms::pixel_coord_lower::Value( - std::array{{static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}}), - uniforms::tile_units_to_pixels::Value(1.0f / tileID.pixelsToTileUnits(1.0f, state.getIntegerZoom())), - }; -} - -} // namespace mbgl diff --git a/src/mbgl/programs/background_program.hpp b/src/mbgl/programs/background_program.hpp deleted file mode 100644 index 205d8cad9..000000000 --- a/src/mbgl/programs/background_program.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -class ImagePosition; -class UnwrappedTileID; -class TransformState; -template -class Faded; - -using BackgroundLayoutAttributes = PositionOnlyLayoutAttributes; - -using BackgroundUniforms = TypeList; - -using BackgroundPatternUniforms = TypeList; - -class BackgroundProgram final : public Program, - style::Properties<>> { -public: - static constexpr std::string_view Name{"BackgroundProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; -}; - -class BackgroundPatternProgram final : public Program, - style::Properties<>> { -public: - static constexpr std::string_view Name{"BackgroundPatternProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutUniformValues layoutUniformValues(mat4 matrix, - float opacity, - Size atlasSize, - const ImagePosition&, - const ImagePosition&, - const CrossfadeParameters&, - const UnwrappedTileID&, - const TransformState&); -}; - -using BackgroundLayoutVertex = BackgroundProgram::LayoutVertex; -using BackgroundAttributes = BackgroundProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/circle_program.cpp b/src/mbgl/programs/circle_program.cpp deleted file mode 100644 index 99b47dd5c..000000000 --- a/src/mbgl/programs/circle_program.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -namespace mbgl { - -static_assert(sizeof(CircleLayoutVertex) == 4, "expected CircleLayoutVertex size"); - -} // namespace mbgl diff --git a/src/mbgl/programs/circle_program.hpp b/src/mbgl/programs/circle_program.hpp deleted file mode 100644 index bb93c6c8f..000000000 --- a/src/mbgl/programs/circle_program.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -namespace mbgl { - -namespace uniforms { -MBGL_DEFINE_UNIFORM_SCALAR(bool, scale_with_map); -} // namespace uniforms - -class CircleProgram final : public Program, - TypeList, - TypeList<>, - style::CirclePaintProperties> { -public: - static constexpr std::string_view Name{"CircleProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - /* - * @param {number} x vertex position - * @param {number} y vertex position - * @param {number} ex extrude normal - * @param {number} ey extrude normal - */ - static LayoutVertex vertex(Point p, float ex, float ey) { - return LayoutVertex{ - {{static_cast((p.x * 2) + ((ex + 1) / 2)), static_cast((p.y * 2) + ((ey + 1) / 2))}}}; - } -}; - -using CircleLayoutVertex = CircleProgram::LayoutVertex; -using CircleAttributes = CircleProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/collision_box_program.cpp b/src/mbgl/programs/collision_box_program.cpp deleted file mode 100644 index 584013640..000000000 --- a/src/mbgl/programs/collision_box_program.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -namespace mbgl { - -static_assert(sizeof(CollisionBoxProgram::LayoutVertex) == 24, "expected CollisionBoxVertex size"); - -} // namespace mbgl diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp deleted file mode 100644 index 2a9635467..000000000 --- a/src/mbgl/programs/collision_box_program.hpp +++ /dev/null @@ -1,168 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include - -namespace mbgl { - -using CollisionBoxLayoutAttributes = TypeList; - -using CollisionBoxDynamicAttributes = TypeList; - -class CollisionBoxProgram final - : public Program, - TypeList, - TypeList<>, - style::Properties<>> { -public: - static constexpr std::string_view Name{"CollisionBoxProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static gfx::Vertex layoutVertex(Point a, Point anchor, Point o) { - return {{{static_cast(a.x), static_cast(a.y)}}, - {{static_cast(anchor.x), static_cast(anchor.y)}}, - {{static_cast(::round(o.x)), static_cast(::round(o.y))}}}; - } - - static gfx::Vertex dynamicVertex(bool placed, bool notUsed, Point shift) { - return {{{static_cast(placed), static_cast(notUsed)}}, {{shift.x, shift.y}}}; - } - - template - void draw(gfx::Context& context, - gfx::RenderPass& renderPass, - const DrawMode& drawMode, - const gfx::DepthMode& depthMode, - const gfx::StencilMode& stencilMode, - const gfx::ColorMode& colorMode, - const gfx::CullFaceMode& cullFaceMode, - const LayoutUniformValues& layoutUniformValues, - const gfx::VertexBuffer>& layoutVertexBuffer, - const gfx::VertexBuffer>& dynamicVertexBuffer, - const gfx::IndexBuffer& indexBuffer, - const SegmentVector& segments, - const Binders& paintPropertyBinders, - const typename PaintProperties::PossiblyEvaluated& currentProperties, - const TextureBindings& textureBindings, - float currentZoom, - const std::string& layerID) { - UniformValues uniformValues = layoutUniformValues.concat( - paintPropertyBinders.uniformValues(currentZoom, currentProperties)); - - AttributeBindings allAttributeBindings = - gfx::AttributeBindings(layoutVertexBuffer) - .concat(gfx::AttributeBindings(dynamicVertexBuffer)) - .concat(paintPropertyBinders.attributeBindings(currentProperties)); - - assert(layoutVertexBuffer.elements == dynamicVertexBuffer.elements); - - for (auto& segment : segments) { - auto drawScopeIt = segment.drawScopes.find(layerID); - - if (drawScopeIt == segment.drawScopes.end()) { - drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first; - } - - program->draw(context, - renderPass, - drawMode, - depthMode, - stencilMode, - colorMode, - cullFaceMode, - uniformValues, - drawScopeIt->second, - allAttributeBindings.offset(segment.vertexOffset), - textureBindings, - indexBuffer, - segment.indexOffset, - segment.indexLength); - } - } -}; - -class CollisionCircleProgram final - : public Program, - TypeList, - TypeList<>, - style::Properties<>> { -public: - static constexpr std::string_view Name{"CollisionCircleProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static gfx::Vertex vertex(Point a, Point anchor, Point o) { - return {{{static_cast(a.x), static_cast(a.y)}}, - {{static_cast(anchor.x), static_cast(anchor.y)}}, - {{static_cast(::round(o.x)), static_cast(::round(o.y))}}}; - } - - template - void draw(gfx::Context& context, - gfx::RenderPass& renderPass, - const DrawMode& drawMode, - const gfx::DepthMode& depthMode, - const gfx::StencilMode& stencilMode, - const gfx::ColorMode& colorMode, - const gfx::CullFaceMode& cullFaceMode, - const LayoutUniformValues& layoutUniformValues, - const gfx::VertexBuffer>& layoutVertexBuffer, - const gfx::VertexBuffer>& dynamicVertexBuffer, - const gfx::IndexBuffer& indexBuffer, - const SegmentVector& segments, - const Binders& paintPropertyBinders, - const typename PaintProperties::PossiblyEvaluated& currentProperties, - const TextureBindings& textureBindings, - float currentZoom, - const std::string& layerID) { - UniformValues uniformValues = layoutUniformValues.concat( - paintPropertyBinders.uniformValues(currentZoom, currentProperties)); - - AttributeBindings allAttributeBindings = - gfx::AttributeBindings(layoutVertexBuffer) - .concat(gfx::AttributeBindings(dynamicVertexBuffer)) - .concat(paintPropertyBinders.attributeBindings(currentProperties)); - - for (auto& segment : segments) { - auto drawScopeIt = segment.drawScopes.find(layerID); - - if (drawScopeIt == segment.drawScopes.end()) { - drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first; - } - - program->draw(context, - renderPass, - drawMode, - depthMode, - stencilMode, - colorMode, - cullFaceMode, - uniformValues, - drawScopeIt->second, - allAttributeBindings.offset(segment.vertexOffset), - textureBindings, - indexBuffer, - segment.indexOffset, - segment.indexLength); - } - } -}; - -} // namespace mbgl diff --git a/src/mbgl/programs/collision_circle_program.hpp b/src/mbgl/programs/collision_circle_program.hpp deleted file mode 100644 index 1fd36af36..000000000 --- a/src/mbgl/programs/collision_circle_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/debug_program.cpp b/src/mbgl/programs/debug_program.cpp deleted file mode 100644 index 5ef4dc378..000000000 --- a/src/mbgl/programs/debug_program.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include - -namespace mbgl {} // namespace mbgl diff --git a/src/mbgl/programs/debug_program.hpp b/src/mbgl/programs/debug_program.hpp deleted file mode 100644 index fe0843798..000000000 --- a/src/mbgl/programs/debug_program.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -namespace mbgl { - -namespace uniforms { -MBGL_DEFINE_UNIFORM_SCALAR(float, overlay_scale); -} -class DebugProgram final : public Program, - TypeList, - TypeList, - style::Properties<>> { -public: - static constexpr std::string_view Name{"DebugProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; -}; - -using DebugLayoutVertex = DebugProgram::LayoutVertex; -using DebugAttributes = DebugProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/fill_extrusion_pattern_program.hpp b/src/mbgl/programs/fill_extrusion_pattern_program.hpp deleted file mode 100644 index b723ce061..000000000 --- a/src/mbgl/programs/fill_extrusion_pattern_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/fill_extrusion_program.cpp b/src/mbgl/programs/fill_extrusion_program.cpp deleted file mode 100644 index 0fc4b85b6..000000000 --- a/src/mbgl/programs/fill_extrusion_program.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include -#include - -namespace mbgl { - -using namespace style; - -static_assert(sizeof(FillExtrusionLayoutVertex) == 12, "expected FillExtrusionLayoutVertex size"); - -std::array FillExtrusionProgram::lightColor(const EvaluatedLight& light) { - const auto color = light.get(); - return {{color.r, color.g, color.b}}; -} - -std::array FillExtrusionProgram::lightPosition(const EvaluatedLight& light, const TransformState& state) { - auto lightPos = light.get().getCartesian(); - mat3 lightMat; - matrix::identity(lightMat); - if (light.get() == LightAnchorType::Viewport) { - matrix::rotate(lightMat, lightMat, -state.getBearing()); - } - matrix::transformMat3f(lightPos, lightPos, lightMat); - return lightPos; -} - -float FillExtrusionProgram::lightIntensity(const EvaluatedLight& light) { - return light.get(); -} - -FillExtrusionProgram::LayoutUniformValues FillExtrusionProgram::layoutUniformValues(const mat4& matrix, - const TransformState& state, - const float opacity, - const EvaluatedLight& light, - const float verticalGradient) { - return {uniforms::matrix::Value(matrix), - uniforms::opacity::Value(opacity), - uniforms::lightcolor::Value(FillExtrusionProgram::lightColor(light)), - uniforms::lightpos::Value(FillExtrusionProgram::lightPosition(light, state)), - uniforms::lightintensity::Value(FillExtrusionProgram::lightIntensity(light)), - uniforms::vertical_gradient::Value(verticalGradient)}; -} - -FillExtrusionPatternProgram::LayoutUniformValues FillExtrusionPatternProgram::layoutUniformValues( - const mat4& matrix, - const Size atlasSize, - const CrossfadeParameters& crossfade, - const UnwrappedTileID& tileID, - const TransformState& state, - const float opacity, - const float heightFactor, - const float pixelRatio, - const EvaluatedLight& light, - const float verticalGradient) { - const auto tileRatio = 1 / tileID.pixelsToTileUnits(1, state.getIntegerZoom()); - const int32_t tileSizeAtNearestZoom = static_cast( - util::tileSize_D * state.zoomScale(state.getIntegerZoom() - tileID.canonical.z)); - const int32_t pixelX = static_cast( - tileSizeAtNearestZoom * (tileID.canonical.x + tileID.wrap * state.zoomScale(tileID.canonical.z))); - const int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y; - - return {uniforms::matrix::Value(matrix), - uniforms::opacity::Value(opacity), - uniforms::scale::Value({{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}}), - uniforms::texsize::Value(atlasSize), - uniforms::fade::Value(crossfade.t), - uniforms::pixel_coord_upper::Value( - std::array{{static_cast(pixelX >> 16), static_cast(pixelY >> 16)}}), - uniforms::pixel_coord_lower::Value( - std::array{{static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}}), - uniforms::height_factor::Value(heightFactor), - uniforms::lightcolor::Value(FillExtrusionProgram::lightColor(light)), - uniforms::lightpos::Value(FillExtrusionProgram::lightPosition(light, state)), - uniforms::lightintensity::Value(FillExtrusionProgram::lightIntensity(light)), - uniforms::vertical_gradient::Value(verticalGradient)}; -} - -} // namespace mbgl diff --git a/src/mbgl/programs/fill_extrusion_program.hpp b/src/mbgl/programs/fill_extrusion_program.hpp deleted file mode 100644 index 2f19b743f..000000000 --- a/src/mbgl/programs/fill_extrusion_program.hpp +++ /dev/null @@ -1,118 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace mbgl { - -class ImagePosition; -class UnwrappedTileID; -class TransformState; -template -class Faded; - -namespace uniforms { -MBGL_DEFINE_UNIFORM_VECTOR(float, 3, lightpos); -MBGL_DEFINE_UNIFORM_VECTOR(float, 3, lightcolor); -MBGL_DEFINE_UNIFORM_SCALAR(float, lightintensity); -MBGL_DEFINE_UNIFORM_SCALAR(float, vertical_gradient); -MBGL_DEFINE_UNIFORM_SCALAR(float, height_factor); -} // namespace uniforms - -using FillExtrusionLayoutAttributes = TypeList; - -using FillExtrusionUniforms = TypeList; - -using FillExtrusionPatternUniforms = TypeList; - -class FillExtrusionProgram final : public Program, - style::FillExtrusionPaintProperties> { -public: - static constexpr std::string_view Name{"FillExtrusionProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutVertex layoutVertex(Point p, double nx, double ny, double nz, unsigned short t, uint16_t e) { - const auto factor = pow(2, 13); - - return LayoutVertex{{{p.x, p.y}}, - {{// Multiply normal vector components by 2^13 to pack them into - // integers We pack a bool (`t`) into the x component indicating - // whether it is an upper or lower vertex - static_cast(floor(nx * factor) * 2 + t), - static_cast(ny * factor * 2), - static_cast(nz * factor * 2), - // The edgedistance attribute is used for wrapping fill_extrusion patterns - static_cast(e)}}}; - } - - static std::array lightColor(const EvaluatedLight&); - static std::array lightPosition(const EvaluatedLight&, const TransformState&); - static float lightIntensity(const EvaluatedLight&); - - static LayoutUniformValues layoutUniformValues( - const mat4&, const TransformState&, float opacity, const EvaluatedLight&, float verticalGradient); -}; - -class FillExtrusionPatternProgram final : public Program, - style::FillExtrusionPaintProperties> { -public: - static constexpr std::string_view Name{"FillExtrusionPatternProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutUniformValues layoutUniformValues(const mat4&, - Size atlasSize, - const CrossfadeParameters&, - const UnwrappedTileID&, - const TransformState&, - float opacity, - float heightFactor, - float pixelRatio, - const EvaluatedLight&, - float verticalGradient); -}; - -using FillExtrusionLayoutVertex = FillExtrusionProgram::LayoutVertex; -using FillExtrusionAttributes = FillExtrusionProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/fill_outline_pattern_program.hpp b/src/mbgl/programs/fill_outline_pattern_program.hpp deleted file mode 100644 index a2c26a168..000000000 --- a/src/mbgl/programs/fill_outline_pattern_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/fill_outline_program.hpp b/src/mbgl/programs/fill_outline_program.hpp deleted file mode 100644 index a2c26a168..000000000 --- a/src/mbgl/programs/fill_outline_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/fill_pattern_program.hpp b/src/mbgl/programs/fill_pattern_program.hpp deleted file mode 100644 index a2c26a168..000000000 --- a/src/mbgl/programs/fill_pattern_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/fill_program.cpp b/src/mbgl/programs/fill_program.cpp deleted file mode 100644 index eb687acbe..000000000 --- a/src/mbgl/programs/fill_program.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include -#include - -namespace mbgl { - -using namespace style; - -static_assert(sizeof(FillLayoutVertex) == 4, "expected FillLayoutVertex size"); - -FillPatternProgram::LayoutUniformValues FillPatternProgram::layoutUniformValues(mat4 matrix, - Size framebufferSize, - Size atlasSize, - const CrossfadeParameters& crossfade, - const UnwrappedTileID& tileID, - const TransformState& state, - const float pixelRatio) { - const auto tileRatio = 1 / tileID.pixelsToTileUnits(1, state.getIntegerZoom()); - int32_t tileSizeAtNearestZoom = static_cast(util::tileSize_D * - state.zoomScale(state.getIntegerZoom() - tileID.canonical.z)); - int32_t pixelX = static_cast(tileSizeAtNearestZoom * - (tileID.canonical.x + tileID.wrap * state.zoomScale(tileID.canonical.z))); - int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y; - - return {uniforms::matrix::Value(matrix), - uniforms::world::Value(framebufferSize), - uniforms::texsize::Value(atlasSize), - uniforms::scale::Value({{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}}), - uniforms::fade::Value(crossfade.t), - uniforms::pixel_coord_upper::Value( - std::array{{static_cast(pixelX >> 16), static_cast(pixelY >> 16)}}), - uniforms::pixel_coord_lower::Value( - std::array{{static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}})}; -} - -} // namespace mbgl diff --git a/src/mbgl/programs/fill_program.hpp b/src/mbgl/programs/fill_program.hpp deleted file mode 100644 index aee0e15c1..000000000 --- a/src/mbgl/programs/fill_program.hpp +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace mbgl { - -class ImagePosition; -class UnwrappedTileID; -class TransformState; -template -class Faded; - -using FillLayoutAttributes = PositionOnlyLayoutAttributes; - -using FillUniforms = TypeList; - -using FillPatternUniforms = TypeList; - -class FillProgram final : public Program, - style::FillPaintProperties> { -public: - static constexpr std::string_view Name{"FillProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutVertex layoutVertex(Point p) { return LayoutVertex{{{p.x, p.y}}}; } -}; - -class FillPatternProgram final : public Program, - style::FillPaintProperties> { -public: - static constexpr std::string_view Name{"FillPatternProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutUniformValues layoutUniformValues(mat4 matrix, - Size framebufferSize, - Size atlasSize, - const CrossfadeParameters& crossfade, - const UnwrappedTileID&, - const TransformState&, - float pixelRatio); -}; - -class FillOutlineProgram final : public Program, - style::FillPaintProperties> { -public: - static constexpr std::string_view Name{"FillOutlineProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; -}; - -class FillOutlinePatternProgram final : public Program, - style::FillPaintProperties> { -public: - static constexpr std::string_view Name{"FillOutlinePatternProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; -}; - -using FillLayoutVertex = FillProgram::LayoutVertex; -using FillAttributes = FillProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/heatmap_program.cpp b/src/mbgl/programs/heatmap_program.cpp deleted file mode 100644 index 67f84fbd5..000000000 --- a/src/mbgl/programs/heatmap_program.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -namespace mbgl { - -static_assert(sizeof(HeatmapLayoutVertex) == 4, "expected HeatmapLayoutVertex size"); - -} // namespace mbgl diff --git a/src/mbgl/programs/heatmap_program.hpp b/src/mbgl/programs/heatmap_program.hpp deleted file mode 100644 index 6404e9c94..000000000 --- a/src/mbgl/programs/heatmap_program.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -namespace uniforms { -MBGL_DEFINE_UNIFORM_SCALAR(float, intensity); -} // namespace uniforms - -class HeatmapProgram final - : public Program, - TypeList, - TypeList<>, - style::HeatmapPaintProperties> { -public: - static constexpr std::string_view Name{"HeatmapProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - /* - * @param {number} x vertex position - * @param {number} y vertex position - * @param {number} ex extrude normal - * @param {number} ey extrude normal - */ - static LayoutVertex vertex(Point p, float ex, float ey) { - return LayoutVertex{ - {{static_cast((p.x * 2) + ((ex + 1) / 2)), static_cast((p.y * 2) + ((ey + 1) / 2))}}}; - } -}; - -using HeatmapLayoutVertex = HeatmapProgram::LayoutVertex; -using HeatmapAttributes = HeatmapProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/heatmap_texture_program.cpp b/src/mbgl/programs/heatmap_texture_program.cpp deleted file mode 100644 index 3b0e24eab..000000000 --- a/src/mbgl/programs/heatmap_texture_program.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -namespace mbgl { - -static_assert(sizeof(HeatmapTextureLayoutVertex) == 4, "expected HeatmapTextureLayoutVertex size"); - -} // namespace mbgl diff --git a/src/mbgl/programs/heatmap_texture_program.hpp b/src/mbgl/programs/heatmap_texture_program.hpp deleted file mode 100644 index 9bce2240f..000000000 --- a/src/mbgl/programs/heatmap_texture_program.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -class HeatmapTextureProgram final : public Program, - TypeList, - TypeList, - style::Properties<>> { -public: - static constexpr std::string_view Name{"HeatmapTextureProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutVertex layoutVertex(Point p) { return LayoutVertex{{{p.x, p.y}}}; } -}; - -using HeatmapTextureLayoutVertex = HeatmapTextureProgram::LayoutVertex; -using HeatmapTextureAttributes = HeatmapTextureProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/hillshade_prepare_program.cpp b/src/mbgl/programs/hillshade_prepare_program.cpp deleted file mode 100644 index 0c0446d3f..000000000 --- a/src/mbgl/programs/hillshade_prepare_program.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -namespace mbgl { - -static_assert(sizeof(HillshadePrepareLayoutVertex) == 8, "expected HillshadeLayoutVertex size"); - -} // namespace mbgl diff --git a/src/mbgl/programs/hillshade_prepare_program.hpp b/src/mbgl/programs/hillshade_prepare_program.hpp deleted file mode 100644 index ef9d8aa42..000000000 --- a/src/mbgl/programs/hillshade_prepare_program.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -namespace mbgl { - -namespace uniforms { -MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, dimension); -MBGL_DEFINE_UNIFORM_SCALAR(float, maxzoom); -MBGL_DEFINE_UNIFORM_VECTOR(float, 4, unpack); -} // namespace uniforms - -class HillshadePrepareProgram final - : public Program< - HillshadePrepareProgram, - shaders::BuiltIn::HillshadePrepareProgram, - gfx::PrimitiveType::Triangle, - TypeList, - TypeList, - TypeList, - style::Properties<>> { -public: - static constexpr std::string_view Name{"HillshadePrepareProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutVertex layoutVertex(Point p, Point t) { - return LayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}}; - } -}; - -using HillshadePrepareLayoutVertex = HillshadePrepareProgram::LayoutVertex; -using HillshadePrepareAttributes = HillshadePrepareProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/hillshade_program.cpp b/src/mbgl/programs/hillshade_program.cpp deleted file mode 100644 index f054ad4b7..000000000 --- a/src/mbgl/programs/hillshade_program.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -namespace mbgl { - -static_assert(sizeof(HillshadeLayoutVertex) == 8, "expected HillshadeLayoutVertex size"); - -} // namespace mbgl diff --git a/src/mbgl/programs/hillshade_program.hpp b/src/mbgl/programs/hillshade_program.hpp deleted file mode 100644 index f88819636..000000000 --- a/src/mbgl/programs/hillshade_program.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -namespace uniforms { -MBGL_DEFINE_UNIFORM_SCALAR(Color, shadow); -MBGL_DEFINE_UNIFORM_SCALAR(Color, highlight); -MBGL_DEFINE_UNIFORM_SCALAR(Color, accent); -MBGL_DEFINE_UNIFORM_VECTOR(float, 2, light); -MBGL_DEFINE_UNIFORM_VECTOR(float, 2, latrange); -} // namespace uniforms - -class HillshadeProgram final : public Program, - TypeList, - TypeList, - style::HillshadePaintProperties> { -public: - static constexpr std::string_view Name{"HillshadeProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutVertex layoutVertex(Point p, Point t) { - return LayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}}; - } -}; - -using HillshadeLayoutVertex = HillshadeProgram::LayoutVertex; -using HillshadeAttributes = HillshadeProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/line_gradient_program.hpp b/src/mbgl/programs/line_gradient_program.hpp deleted file mode 100644 index c98cd37e9..000000000 --- a/src/mbgl/programs/line_gradient_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/line_pattern_program.hpp b/src/mbgl/programs/line_pattern_program.hpp deleted file mode 100644 index c98cd37e9..000000000 --- a/src/mbgl/programs/line_pattern_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/line_program.cpp b/src/mbgl/programs/line_program.cpp deleted file mode 100644 index a14c4528a..000000000 --- a/src/mbgl/programs/line_program.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -using namespace style; - -static_assert(sizeof(LineLayoutVertex) == 8, "expected LineLayoutVertex size"); - -template -Values makeValues(const style::LinePaintProperties::PossiblyEvaluated& properties, - const RenderTile& tile, - const TransformState& state, - const std::array& pixelsToGLUnits, - const float pixelRatio, - Args&&... args) { - return Values{uniforms::matrix::Value(tile.translatedMatrix( - properties.get(), properties.get(), state)), - uniforms::ratio::Value(1.0f / tile.id.pixelsToTileUnits(1.0f, static_cast(state.getZoom()))), - uniforms::units_to_pixels::Value({{1.0f / pixelsToGLUnits[0], 1.0f / pixelsToGLUnits[1]}}), - uniforms::device_pixel_ratio::Value(pixelRatio), - std::forward(args)...}; -} - -LineProgram::LayoutUniformValues LineProgram::layoutUniformValues( - const style::LinePaintProperties::PossiblyEvaluated& properties, - const RenderTile& tile, - const TransformState& state, - const std::array& pixelsToGLUnits, - const float pixelRatio) { - return makeValues(properties, tile, state, pixelsToGLUnits, pixelRatio); -} - -LineSDFProgram::LayoutUniformValues LineSDFProgram::layoutUniformValues( - const style::LinePaintProperties::PossiblyEvaluated& properties, - float pixelRatio, - const RenderTile& tile, - const TransformState& state, - const std::array& pixelsToGLUnits, - const LinePatternPos& posA, - const LinePatternPos& posB, - const CrossfadeParameters& crossfade, - float atlasWidth) { - const float widthA = posA.width * crossfade.fromScale; - const float widthB = posB.width * crossfade.toScale; - - std::array scaleA{ - {1.0f / tile.id.pixelsToTileUnits(widthA, state.getIntegerZoom()), -posA.height / 2.0f}}; - - std::array scaleB{ - {1.0f / tile.id.pixelsToTileUnits(widthB, state.getIntegerZoom()), -posB.height / 2.0f}}; - - return makeValues( - properties, - tile, - state, - pixelsToGLUnits, - pixelRatio, - uniforms::patternscale_a::Value(scaleA), - uniforms::patternscale_b::Value(scaleB), - uniforms::tex_y_a::Value(posA.y), - uniforms::tex_y_b::Value(posB.y), - uniforms::mix::Value(crossfade.t), - uniforms::sdfgamma::Value(atlasWidth / (std::min(widthA, widthB) * 256.0f * pixelRatio) / 2.0f)); -} - -LinePatternProgram::LayoutUniformValues LinePatternProgram::layoutUniformValues( - const style::LinePaintProperties::PossiblyEvaluated& properties, - const RenderTile& tile, - const TransformState& state, - const std::array& pixelsToGLUnits, - const float pixelRatio, - const Size atlasSize, - const CrossfadeParameters& crossfade) { - const auto tileRatio = 1 / tile.id.pixelsToTileUnits(1, state.getIntegerZoom()); - - return makeValues( - properties, - tile, - state, - pixelsToGLUnits, - pixelRatio, - uniforms::scale::Value({{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}}), - uniforms::texsize::Value(atlasSize), - uniforms::fade::Value(crossfade.t)); -} - -LineGradientProgram::LayoutUniformValues LineGradientProgram::layoutUniformValues( - const style::LinePaintProperties::PossiblyEvaluated& properties, - const RenderTile& tile, - const TransformState& state, - const std::array& pixelsToGLUnits, - const float pixelRatio) { - return makeValues(properties, tile, state, pixelsToGLUnits, pixelRatio); -} - -} // namespace mbgl diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp deleted file mode 100644 index 122ebd6ad..000000000 --- a/src/mbgl/programs/line_program.hpp +++ /dev/null @@ -1,180 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace mbgl { - -class RenderTile; -class TransformState; -class LinePatternPos; -class ImagePosition; - -namespace uniforms { -MBGL_DEFINE_UNIFORM_SCALAR(float, ratio); -MBGL_DEFINE_UNIFORM_SCALAR(float, tex_y_a); -MBGL_DEFINE_UNIFORM_SCALAR(float, tex_y_b); -MBGL_DEFINE_UNIFORM_SCALAR(float, sdfgamma); -MBGL_DEFINE_UNIFORM_VECTOR(float, 2, patternscale_a); -MBGL_DEFINE_UNIFORM_VECTOR(float, 2, patternscale_b); -MBGL_DEFINE_UNIFORM_VECTOR(float, 2, units_to_pixels); -} // namespace uniforms - -using LineLayoutAttributes = TypeList>; - -class LineProgram final - : public Program< - LineProgram, - shaders::BuiltIn::LineProgram, - gfx::PrimitiveType::Triangle, - LineLayoutAttributes, - TypeList, - TypeList<>, - style::LinePaintProperties> { -public: - static constexpr std::string_view Name{"LineProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - /* - * @param p vertex position - * @param e extrude normal - * @param round whether the vertex uses a round line cap - * @param up whether the line normal points up or down - * @param dir direction of the line cap (-1/0/1) - */ - static LayoutVertex layoutVertex( - Point p, Point e, bool round, bool up, int8_t dir, int32_t linesofar = 0) { - return LayoutVertex{ - {{static_cast((p.x * 2) | (round ? 1 : 0)), static_cast((p.y * 2) | (up ? 1 : 0))}}, - {{// add 128 to store a byte in an unsigned byte - static_cast(util::clamp(::round(extrudeScale * e.x) + 128, 0., 255.)), - static_cast(util::clamp(::round(extrudeScale * e.y) + 128, 0., 255.)), - - // Encode the -1/0/1 direction value into the first two bits of .z - // of a_data. Combine it with the lower 6 bits of `linesofar` - // (shifted by 2 bites to make room for the direction value). The - // upper 8 bits of `linesofar` are placed in the `w` component. - // `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that we - // can store longer distances while sacrificing precision. - - // Encode the -1/0/1 direction value into .zw coordinates of - // a_data, which is normally covered by linesofar, so we need to - // merge them. The z component's first bit, as well as the sign - // bit is reserved for the direction, so we need to shift the - // linesofar. - static_cast(((dir == 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofar & 0x3F) << 2)), - static_cast(linesofar >> 6)}}}; - } - - /* - * Scale the extrusion vector so that the normal length is this value. - * Contains the "texture" normals (-1..1). This is distinct from the extrude - * normals for line joins, because the x-value remains 0 for the texture - * normal array, while the extrude normal actually moves the vertex to - * create the acute/bevelled line join. - */ - static const int8_t extrudeScale = 63; - - static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&, - const RenderTile&, - const TransformState&, - const std::array& pixelsToGLUnits, - float pixelRatio); -}; - -class LinePatternProgram final : public Program, - TypeList, - style::LinePaintProperties> { -public: - static constexpr std::string_view Name{"LinePatternProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&, - const RenderTile&, - const TransformState&, - const std::array& pixelsToGLUnits, - float pixelRatio, - Size atlasSize, - const CrossfadeParameters& crossfade); -}; - -class LineSDFProgram final : public Program, - TypeList, - style::LinePaintProperties> { -public: - static constexpr std::string_view Name{"LineSDFProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&, - float pixelRatio, - const RenderTile&, - const TransformState&, - const std::array& pixelsToGLUnits, - const LinePatternPos& posA, - const LinePatternPos& posB, - const CrossfadeParameters& crossfade, - float atlasWidth); -}; - -class LineGradientProgram final - : public Program< - LineGradientProgram, - shaders::BuiltIn::LineGradientProgram, - gfx::PrimitiveType::Triangle, - LineLayoutAttributes, - TypeList, - TypeList, - style::LinePaintProperties> { -public: - static constexpr std::string_view Name{"LineGradientProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&, - const RenderTile&, - const TransformState&, - const std::array& pixelsToGLUnits, - float pixelRatio); -}; - -using LineLayoutVertex = LineProgram::LayoutVertex; -using LineAttributes = LineProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/line_sdf_program.hpp b/src/mbgl/programs/line_sdf_program.hpp deleted file mode 100644 index c98cd37e9..000000000 --- a/src/mbgl/programs/line_sdf_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp index 439c36ca5..59772f3fe 100644 --- a/src/mbgl/programs/program.hpp +++ b/src/mbgl/programs/program.hpp @@ -105,7 +105,7 @@ public: const gfx::ColorMode& colorMode, const gfx::CullFaceMode& cullFaceMode, const gfx::IndexBuffer& indexBuffer, - const Segment& segment, + const SegmentBase& segment, const UniformValues& uniformValues, const AttributeBindings& allAttributeBindings, const TextureBindings& textureBindings, @@ -146,7 +146,7 @@ public: const gfx::ColorMode& colorMode, const gfx::CullFaceMode& cullFaceMode, const gfx::IndexBuffer& indexBuffer, - const SegmentVector& segments, + const SegmentVector& segments, const UniformValues& uniformValues, const AttributeBindings& allAttributeBindings, const TextureBindings& textureBindings, diff --git a/src/mbgl/programs/programs.cpp b/src/mbgl/programs/programs.cpp index 6b35265df..2f7591b8a 100644 --- a/src/mbgl/programs/programs.cpp +++ b/src/mbgl/programs/programs.cpp @@ -1,13 +1,4 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include @@ -41,7 +32,7 @@ void registerTypes(gfx::ShaderRegistry& registry, const ProgramParameters& progr void Programs::registerWith(gfx::ShaderRegistry& registry) { /// The following types will be registered - registerTypes(registry, programParameters); + registerTypes(registry, programParameters); } } // namespace mbgl diff --git a/src/mbgl/programs/programs.hpp b/src/mbgl/programs/programs.hpp index 9049a2337..136209e25 100644 --- a/src/mbgl/programs/programs.hpp +++ b/src/mbgl/programs/programs.hpp @@ -1,24 +1,12 @@ #pragma once #include -#include #include #include #include namespace mbgl { -class BackgroundLayerPrograms; - -class CircleLayerPrograms; -class RasterLayerPrograms; -class HeatmapLayerPrograms; -class HillshadeLayerPrograms; -class FillLayerPrograms; -class FillExtrusionLayerPrograms; -class LineLayerPrograms; -class SymbolLayerPrograms; - class Programs { public: Programs(const ProgramParameters&); diff --git a/src/mbgl/programs/raster_program.cpp b/src/mbgl/programs/raster_program.cpp deleted file mode 100644 index 6906903e6..000000000 --- a/src/mbgl/programs/raster_program.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -namespace mbgl { - -static_assert(sizeof(RasterLayoutVertex) == 8, "expected RasterLayoutVertex size"); - -} // namespace mbgl diff --git a/src/mbgl/programs/raster_program.hpp b/src/mbgl/programs/raster_program.hpp deleted file mode 100644 index 491ad3f83..000000000 --- a/src/mbgl/programs/raster_program.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -namespace uniforms { -MBGL_DEFINE_UNIFORM_SCALAR(float, fade_t); -MBGL_DEFINE_UNIFORM_SCALAR(float, buffer_scale); -MBGL_DEFINE_UNIFORM_SCALAR(float, brightness_low); -MBGL_DEFINE_UNIFORM_SCALAR(float, brightness_high); -MBGL_DEFINE_UNIFORM_SCALAR(float, saturation_factor); -MBGL_DEFINE_UNIFORM_SCALAR(float, contrast_factor); -MBGL_DEFINE_UNIFORM_SCALAR(float, scale_parent); -MBGL_DEFINE_UNIFORM_VECTOR(float, 3, spin_weights); -MBGL_DEFINE_UNIFORM_VECTOR(float, 2, tl_parent); -} // namespace uniforms - -class RasterProgram final : public Program, - TypeList, - TypeList, - style::RasterPaintProperties> { -public: - static constexpr std::string_view Name{"RasterProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using Program::Program; - - static LayoutVertex layoutVertex(Point p, Point t) { - return LayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}}; - } -}; - -using RasterLayoutVertex = RasterProgram::LayoutVertex; -using RasterAttributes = RasterProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/segment.hpp b/src/mbgl/programs/segment.hpp index bed60cea7..8d240c465 100644 --- a/src/mbgl/programs/segment.hpp +++ b/src/mbgl/programs/segment.hpp @@ -47,12 +47,6 @@ public: float sortKey; }; -template -class Segment : public SegmentBase { - using SegmentBase::SegmentBase; -}; - -template -using SegmentVector = std::vector>; +using SegmentVector = std::vector; } // namespace mbgl diff --git a/src/mbgl/programs/symbol_icon_program.hpp b/src/mbgl/programs/symbol_icon_program.hpp deleted file mode 100644 index 57f27518d..000000000 --- a/src/mbgl/programs/symbol_icon_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp deleted file mode 100644 index 52037f8c0..000000000 --- a/src/mbgl/programs/symbol_program.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -using namespace style; - -static_assert(sizeof(SymbolLayoutVertex) == 24, "expected SymbolLayoutVertex size"); - -std::unique_ptr SymbolSizeBinder::create(const float tileZoom, - const style::PropertyValue& sizeProperty, - const float defaultValue) { - return sizeProperty.match( - [&](const Undefined& value) -> std::unique_ptr { - return std::make_unique(tileZoom, value, defaultValue); - }, - [&](float value) -> std::unique_ptr { - return std::make_unique(tileZoom, value, defaultValue); - }, - [&](const style::PropertyExpression& expression) -> std::unique_ptr { - if (expression.isFeatureConstant()) { - return std::make_unique(tileZoom, expression, defaultValue); - } else if (expression.isZoomConstant()) { - return std::make_unique(tileZoom, expression, defaultValue); - } else { - return std::make_unique(tileZoom, expression, defaultValue); - } - }); -} - -template -Values makeValues(const bool isText, - const bool hasVariablePacement, - const style::SymbolPropertyValues& values, - const Size& texsize, - const std::array& pixelsToGLUnits, - const bool alongLine, - const RenderTile& tile, - const TransformState& state, - const float symbolFadeChange, - Args&&... args) { - std::array extrudeScale; - - if (values.pitchAlignment == AlignmentType::Map) { - extrudeScale.fill(tile.id.pixelsToTileUnits(1.f, static_cast(state.getZoom()))); - } else { - extrudeScale = {{pixelsToGLUnits[0] * state.getCameraToCenterDistance(), - pixelsToGLUnits[1] * state.getCameraToCenterDistance()}}; - } - - const float pixelsToTileUnits = tile.id.pixelsToTileUnits(1.f, static_cast(state.getZoom())); - const bool pitchWithMap = values.pitchAlignment == style::AlignmentType::Map; - const bool rotateWithMap = values.rotationAlignment == style::AlignmentType::Map; - - // Line label rotation happens in `updateLineLabels`/`reprojectLineLabels`` - // Pitched point labels are automatically rotated by the labelPlaneMatrix projection - // Unpitched point labels need to have their rotation applied after projection - const bool rotateInShader = rotateWithMap && !pitchWithMap && !alongLine; - - mat4 labelPlaneMatrix; - if (alongLine || hasVariablePacement) { - // For labels that follow lines the first part of the projection is - // handled on the cpu. Pass an identity matrix because no transformation - // needs to be done in the vertex shader. - matrix::identity(labelPlaneMatrix); - } else { - labelPlaneMatrix = getLabelPlaneMatrix(tile.matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits); - } - - mat4 glCoordMatrix = getGlCoordMatrix(tile.matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits); - - return Values{uniforms::matrix::Value(tile.translatedMatrix(values.translate, values.translateAnchor, state)), - uniforms::label_plane_matrix::Value(labelPlaneMatrix), - uniforms::coord_matrix::Value( - tile.translateVtxMatrix(glCoordMatrix, values.translate, values.translateAnchor, state, true)), - uniforms::extrude_scale::Value(extrudeScale), - uniforms::texsize::Value(texsize), - uniforms::fade_change::Value(symbolFadeChange), - uniforms::is_text::Value(isText), - uniforms::camera_to_center_distance::Value(state.getCameraToCenterDistance()), - uniforms::pitch::Value(state.getPitch()), - uniforms::pitch_with_map::Value(pitchWithMap), - uniforms::rotate_symbol::Value(rotateInShader), - uniforms::aspect_ratio::Value(state.getSize().aspectRatio()), - std::forward(args)...}; -} - -SymbolIconProgram::LayoutUniformValues SymbolIconProgram::layoutUniformValues( - const bool isText, - const bool hasVariablePacement, - const style::SymbolPropertyValues& values, - const Size& texsize, - const std::array& pixelsToGLUnits, - const bool alongLine, - const RenderTile& tile, - const TransformState& state, - const float symbolFadeChange) { - return makeValues( - isText, hasVariablePacement, values, texsize, pixelsToGLUnits, alongLine, tile, state, symbolFadeChange); -} - -template -typename SymbolSDFProgram::LayoutUniformValues -SymbolSDFProgram::layoutUniformValues(const bool isText, - const bool hasVariablePacement, - const style::SymbolPropertyValues& values, - const Size& texsize, - const std::array& pixelsToGLUnits, - const float pixelRatio, - const bool alongLine, - const RenderTile& tile, - const TransformState& state, - const float symbolFadeChange, - const SymbolSDFPart part) { - const float gammaScale = (values.pitchAlignment == AlignmentType::Map - ? static_cast(std::cos(state.getPitch())) * state.getCameraToCenterDistance() - : 1.0f); - - return makeValues::LayoutUniformValues>( - isText, - hasVariablePacement, - values, - texsize, - pixelsToGLUnits, - alongLine, - tile, - state, - symbolFadeChange, - uniforms::gamma_scale::Value(gammaScale), - uniforms::device_pixel_ratio::Value(pixelRatio), - uniforms::is_halo::Value(part == SymbolSDFPart::Halo)); -} - -SymbolTextAndIconProgram::LayoutUniformValues SymbolTextAndIconProgram::layoutUniformValues( - const bool hasVariablePacement, - const style::SymbolPropertyValues& values, - const Size& texsize, - const Size& texsize_icon, - const std::array& pixelsToGLUnits, - const float pixelRatio, - const bool alongLine, - const RenderTile& tile, - const TransformState& state, - const float symbolFadeChange, - const SymbolSDFPart part) { - return {SymbolSDFProgram::layoutUniformValues(true, - hasVariablePacement, - values, - texsize, - pixelsToGLUnits, - pixelRatio, - alongLine, - tile, - state, - symbolFadeChange, - part) - .concat(gfx::UniformValues(uniforms::texsize::Value(texsize_icon)))}; -} - -template class SymbolSDFProgram; -template class SymbolSDFProgram; - -} // namespace mbgl diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp deleted file mode 100644 index 4aadbbc1b..000000000 --- a/src/mbgl/programs/symbol_program.hpp +++ /dev/null @@ -1,551 +0,0 @@ -#pragma once - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#if MLN_RENDER_BACKEND_OPENGL -#include -#endif - -namespace mbgl { - -const uint16_t MAX_GLYPH_ICON_SIZE = 255; -const uint16_t SIZE_PACK_FACTOR = 128; -const uint16_t MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR; - -namespace style { -class SymbolPropertyValues; -} // namespace style - -class RenderTile; -class TransformState; - -namespace uniforms { -MBGL_DEFINE_UNIFORM_MATRIX(double, 4, coord_matrix); -MBGL_DEFINE_UNIFORM_MATRIX(double, 4, label_plane_matrix); -MBGL_DEFINE_UNIFORM_SCALAR(bool, is_halo); -MBGL_DEFINE_UNIFORM_SCALAR(float, gamma_scale); - -MBGL_DEFINE_UNIFORM_SCALAR(bool, is_text); -MBGL_DEFINE_UNIFORM_SCALAR(bool, is_size_zoom_constant); -MBGL_DEFINE_UNIFORM_SCALAR(bool, is_size_feature_constant); -MBGL_DEFINE_UNIFORM_SCALAR(float, size_t); -MBGL_DEFINE_UNIFORM_SCALAR(float, size); -MBGL_DEFINE_UNIFORM_SCALAR(bool, rotate_symbol); -MBGL_DEFINE_UNIFORM_SCALAR(float, aspect_ratio); -} // namespace uniforms - -using SymbolLayoutAttributes = TypeList, attributes::pixeloffset>; - -using SymbolDynamicLayoutAttributes = TypeList; - -using SymbolOpacityAttributes = TypeList; - -struct ZoomEvaluatedSize { - bool isZoomConstant; - bool isFeatureConstant; - float sizeT; - float size; - float layoutSize; -}; -// Mimic the PaintPropertyBinder technique specifically for the {text,icon}-size -// layout properties in order to provide a 'custom' scheme for encoding the -// necessary attribute data. As with PaintPropertyBinder, SymbolSizeBinder is -// an abstract class whose implementations handle the particular attribute & -// uniform logic needed by each possible type of the {Text,Icon}Size properties. -class SymbolSizeBinder { -public: - virtual ~SymbolSizeBinder() = default; - - using UniformList = - TypeList; - using UniformValues = gfx::UniformValues; - - static std::unique_ptr create(float tileZoom, - const style::PropertyValue& sizeProperty, - float defaultValue); - - virtual Range getVertexSizeData(const GeometryTileFeature& feature) = 0; - virtual ZoomEvaluatedSize evaluateForZoom(float currentZoom) const = 0; - - UniformValues uniformValues(float currentZoom) const { - const ZoomEvaluatedSize u = evaluateForZoom(currentZoom); - return UniformValues{uniforms::is_size_zoom_constant::Value(u.isZoomConstant), - uniforms::is_size_feature_constant::Value(u.isFeatureConstant), - uniforms::size_t::Value(u.sizeT), - uniforms::size::Value(u.size)}; - } -}; - -class ConstantSymbolSizeBinder final : public SymbolSizeBinder { -public: - ConstantSymbolSizeBinder(const float /*tileZoom*/, const float& size, const float /*defaultValue*/) noexcept - : layoutSize(size) {} - - ConstantSymbolSizeBinder(const float /*tileZoom*/, const style::Undefined&, const float defaultValue) noexcept - : layoutSize(defaultValue) {} - - ConstantSymbolSizeBinder(const float tileZoom, - const style::PropertyExpression& expression_, - const float /*defaultValue*/ - ) - : layoutSize(expression_.evaluate(tileZoom + 1)), - expression(expression_) { - const Range zoomLevels = expression_.getCoveringStops(tileZoom, tileZoom + 1); - coveringRanges = std::make_tuple( - zoomLevels, Range{expression_.evaluate(zoomLevels.min), expression_.evaluate(zoomLevels.max)}); - } - - Range getVertexSizeData(const GeometryTileFeature&) noexcept override { return {0.0f, 0.0f}; }; - - ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override { - float size = layoutSize; - bool isZoomConstant = !(coveringRanges || expression); - if (coveringRanges) { - // Even though we could get the exact value of the camera function - // at z = currentZoom, we intentionally do not: instead, we - // interpolate between the camera function values at a pair of zoom - // stops covering [tileZoom, tileZoom + 1] in order to be consistent - // with this restriction on composite functions. - const Range& zoomLevels = std::get<0>(*coveringRanges); - const Range& sizeLevels = std::get<1>(*coveringRanges); - float t = util::clamp(expression->interpolationFactor(zoomLevels, currentZoom), 0.0f, 1.0f); - size = sizeLevels.min + t * (sizeLevels.max - sizeLevels.min); - } else if (expression) { - size = expression->evaluate(currentZoom); - } - - const float unused = 0.0f; - return {.isZoomConstant = isZoomConstant, - .isFeatureConstant = true, - .sizeT = unused, - .size = size, - .layoutSize = layoutSize}; - } - - float layoutSize; - std::optional, Range>> coveringRanges; - std::optional> expression; -}; - -class SourceFunctionSymbolSizeBinder final : public SymbolSizeBinder { -public: - SourceFunctionSymbolSizeBinder(const float /*tileZoom*/, - style::PropertyExpression expression_, - const float defaultValue_) noexcept - : expression(std::move(expression_)), - defaultValue(defaultValue_) {} - - Range getVertexSizeData(const GeometryTileFeature& feature) override { - const float size = expression.evaluate(feature, defaultValue); - return {size, size}; - }; - - ZoomEvaluatedSize evaluateForZoom(float) const noexcept override { - const float unused = 0.0f; - return { - .isZoomConstant = true, .isFeatureConstant = false, .sizeT = unused, .size = unused, .layoutSize = unused}; - } - - style::PropertyExpression expression; - const float defaultValue; -}; - -class CompositeFunctionSymbolSizeBinder final : public SymbolSizeBinder { -public: - CompositeFunctionSymbolSizeBinder(const float tileZoom, - style::PropertyExpression expression_, - const float defaultValue_) noexcept - : expression(std::move(expression_)), - defaultValue(defaultValue_), - layoutZoom(tileZoom + 1), - coveringZoomStops(expression.getCoveringStops(tileZoom, tileZoom + 1)) {} - - Range getVertexSizeData(const GeometryTileFeature& feature) override { - return {expression.evaluate(coveringZoomStops.min, feature, defaultValue), - expression.evaluate(coveringZoomStops.max, feature, defaultValue)}; - }; - - ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override { - float sizeInterpolationT = util::clamp( - expression.interpolationFactor(coveringZoomStops, currentZoom), 0.0f, 1.0f); - - const float unused = 0.0f; - return {.isZoomConstant = false, - .isFeatureConstant = false, - .sizeT = sizeInterpolationT, - .size = unused, - .layoutSize = unused}; - } - - style::PropertyExpression expression; - const float defaultValue; - float layoutZoom; - Range coveringZoomStops; -}; - -class SymbolProgramBase : public gfx::Shader { -public: - static gfx::Vertex layoutVertex(Point labelAnchor, - Point o, - float glyphOffsetY, - uint16_t tx, - uint16_t ty, - const Range& sizeData, - bool isSDF, - Point pixelOffset, - Point minFontScale) { - const uint16_t aSizeMin = (std::min(MAX_PACKED_SIZE, static_cast(sizeData.min * SIZE_PACK_FACTOR)) - << 1) + - uint16_t(isSDF); - const uint16_t aSizeMax = std::min(MAX_PACKED_SIZE, static_cast(sizeData.max * SIZE_PACK_FACTOR)); - return { - // combining pos and offset to reduce number of vertex attributes - // passed to shader (8 max for some devices) - {{static_cast(labelAnchor.x), - static_cast(labelAnchor.y), - static_cast(std::round(o.x * 32)), // use 1/32 pixels for placement - static_cast(std::round((o.y + glyphOffsetY) * 32))}}, - {{tx, ty, aSizeMin, aSizeMax}}, - {{static_cast(pixelOffset.x * 16), - static_cast(pixelOffset.y * 16), - static_cast(minFontScale.x * 256), - static_cast(minFontScale.y * 256)}}, - }; - } - - static gfx::Vertex dynamicLayoutVertex(Point anchorPoint, float labelAngle) { - return {{{anchorPoint.x, anchorPoint.y, labelAngle}}}; - } - - static gfx::Vertex opacityVertex(bool placed, float opacity) { - return {{{static_cast((static_cast(opacity * 127) << 1) | static_cast(placed))}}}; - } -}; - -template -class SymbolProgram : public SymbolProgramBase { -public: - using LayoutVertex = gfx::Vertex; - - using LayoutAndSizeAttributeList = - TypeListConcat; - - using PaintProperties = PaintProps; - using Binders = PaintPropertyBinders; - - using PaintAttributeList = typename Binders::AttributeList; - using AttributeList = TypeListConcat; - using AttributeBindings = gfx::AttributeBindings; - - using LayoutUniformValues = gfx::UniformValues; - using SizeUniformList = typename SymbolSizeBinder::UniformList; - using PaintUniformList = typename Binders::UniformList; - using UniformList = TypeListConcat; - using UniformValues = gfx::UniformValues; - - using TextureList = Textures; - using TextureBindings = gfx::TextureBindings; - - std::unique_ptr> program; - - // NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility) - SymbolProgram([[maybe_unused]] const ProgramParameters& programParameters) { - switch (gfx::Backend::GetType()) { -#if MLN_RENDER_BACKEND_OPENGL - case gfx::Backend::Type::OpenGL: { - program = std::make_unique>(programParameters.withDefaultSource( - {gfx::Backend::Type::OpenGL, - shaders::ShaderSource::vertex, - shaders::ShaderSource::fragment})); - break; - } -#endif - default: { - throw std::runtime_error("Unsupported rendering backend!"); - } - } - } - - static UniformValues computeAllUniformValues(const LayoutUniformValues& layoutUniformValues, - const SymbolSizeBinder& symbolSizeBinder, - const Binders& paintPropertyBinders, - const typename PaintProperties::PossiblyEvaluated& currentProperties, - float currentZoom) { - return layoutUniformValues.concat(symbolSizeBinder.uniformValues(currentZoom)) - .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); - } - - static AttributeBindings computeAllAttributeBindings( - const gfx::VertexBuffer& layoutVertexBuffer, - const gfx::VertexBuffer>& dynamicLayoutVertexBuffer, - const gfx::VertexBuffer>& opacityVertexBuffer, - const Binders& paintPropertyBinders, - const typename PaintProperties::PossiblyEvaluated& currentProperties) { - assert(layoutVertexBuffer.elements == dynamicLayoutVertexBuffer.elements && - layoutVertexBuffer.elements == opacityVertexBuffer.elements); - return gfx::AttributeBindings(layoutVertexBuffer) - .concat(gfx::AttributeBindings(dynamicLayoutVertexBuffer)) - .concat(gfx::AttributeBindings(opacityVertexBuffer)) - .concat(paintPropertyBinders.attributeBindings(currentProperties)); - } - - static uint32_t activeBindingCount(const AttributeBindings& allAttributeBindings) { - return allAttributeBindings.activeCount(); - } - - template - void draw(gfx::Context& context, - gfx::RenderPass& renderPass, - const DrawMode& drawMode, - const gfx::DepthMode& depthMode, - const gfx::StencilMode& stencilMode, - const gfx::ColorMode& colorMode, - const gfx::CullFaceMode& cullFaceMode, - const gfx::IndexBuffer& indexBuffer, - const Segment& segment, - const UniformValues& uniformValues, - const AttributeBindings& allAttributeBindings, - const TextureBindings& textureBindings, - const std::string& layerID) { - static_assert(Primitive == gfx::PrimitiveTypeOf::value, "incompatible draw mode"); - - if (!program) { - return; - } - - auto drawScopeIt = segment.drawScopes.find(layerID); - if (drawScopeIt == segment.drawScopes.end()) { - drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first; - } - - program->draw(context, - renderPass, - drawMode, - depthMode, - stencilMode, - colorMode, - cullFaceMode, - uniformValues, - drawScopeIt->second, - allAttributeBindings.offset(segment.vertexOffset), - textureBindings, - indexBuffer, - segment.indexOffset, - segment.indexLength); - } - - template - void draw(gfx::Context& context, - gfx::RenderPass& renderPass, - const DrawMode& drawMode, - const gfx::DepthMode& depthMode, - const gfx::StencilMode& stencilMode, - const gfx::ColorMode& colorMode, - const gfx::CullFaceMode& cullFaceMode, - const gfx::IndexBuffer& indexBuffer, - const SegmentVector& segments, - const UniformValues& uniformValues, - const AttributeBindings& allAttributeBindings, - const TextureBindings& textureBindings, - const std::string& layerID) { - static_assert(Primitive == gfx::PrimitiveTypeOf::value, "incompatible draw mode"); - - if (!program) { - return; - } - - for (const auto& segment : segments) { - draw(context, - renderPass, - drawMode, - depthMode, - stencilMode, - colorMode, - cullFaceMode, - indexBuffer, - segment, - uniformValues, - allAttributeBindings, - textureBindings, - layerID); - } - } -}; - -class SymbolIconProgram final : public SymbolProgram, - TypeList, - style::IconPaintProperties> { -public: - static constexpr std::string_view Name{"SymbolIconProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using SymbolProgram::SymbolProgram; - - static LayoutUniformValues layoutUniformValues(bool isText, - bool hasVariablePacement, - const style::SymbolPropertyValues&, - const Size& texsize, - const std::array& pixelsToGLUnits, - bool alongLine, - const RenderTile&, - const TransformState&, - float symbolFadeChange); -}; - -enum class SymbolSDFPart { - Fill = 1, - Halo = 0 -}; - -using SymbolSDFProgramUniforms = TypeList; - -template -// NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility) -class SymbolSDFProgram : public SymbolProgram, - PaintProperties> { -public: - using BaseProgram = SymbolProgram, - PaintProperties>; - - using LayoutUniformValues = typename BaseProgram::LayoutUniformValues; - - using BaseProgram::BaseProgram; - - static LayoutUniformValues layoutUniformValues(bool isText, - bool hasVariablePacement, - const style::SymbolPropertyValues&, - const Size& texsize, - const std::array& pixelsToGLUnits, - float pixelRatio, - bool alongLine, - const RenderTile&, - const TransformState&, - float SymbolFadeChange, - SymbolSDFPart); -}; - -using SymbolTextAndIconProgramUniforms = TypeList; - -class SymbolTextAndIconProgram final - : public SymbolProgram, - TypeList, - style::TextPaintProperties> { -public: - static constexpr std::string_view Name{"SymbolTextAndIconProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using BaseProgram = SymbolProgram, - TypeList, - style::TextPaintProperties>; - - using LayoutUniformValues = typename BaseProgram::LayoutUniformValues; - - using BaseProgram::BaseProgram; - - static LayoutUniformValues layoutUniformValues(bool hasVariablePacement, - const style::SymbolPropertyValues&, - const Size& texsize, - const Size& texsize_icon, - const std::array& pixelsToGLUnits, - float pixelRatio, - bool alongLine, - const RenderTile&, - const TransformState&, - float SymbolFadeChange, - SymbolSDFPart); -}; - -class SymbolSDFIconProgram final : public SymbolSDFProgram { -public: - static constexpr std::string_view Name{"SymbolSDFIconProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using SymbolSDFProgram::SymbolSDFProgram; -}; - -class SymbolSDFTextProgram final : public SymbolSDFProgram { -public: - static constexpr std::string_view Name{"SymbolSDFTextProgram"}; - const std::string_view typeName() const noexcept override { return Name; } - - using SymbolSDFProgram::SymbolSDFProgram; -}; - -using SymbolLayoutVertex = gfx::Vertex; -using SymbolIconAttributes = SymbolIconProgram::AttributeList; -using SymbolTextAttributes = SymbolSDFTextProgram::AttributeList; - -} // namespace mbgl diff --git a/src/mbgl/programs/symbol_sdf_icon_program.hpp b/src/mbgl/programs/symbol_sdf_icon_program.hpp deleted file mode 100644 index 57f27518d..000000000 --- a/src/mbgl/programs/symbol_sdf_icon_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/symbol_sdf_text_program.hpp b/src/mbgl/programs/symbol_sdf_text_program.hpp deleted file mode 100644 index 57f27518d..000000000 --- a/src/mbgl/programs/symbol_sdf_text_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/programs/symbol_text_and_icon_program.hpp b/src/mbgl/programs/symbol_text_and_icon_program.hpp deleted file mode 100644 index 57f27518d..000000000 --- a/src/mbgl/programs/symbol_text_and_icon_program.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -// Alias -#include diff --git a/src/mbgl/renderer/buckets/circle_bucket.cpp b/src/mbgl/renderer/buckets/circle_bucket.cpp index fbcf430d7..8fbb4e955 100644 --- a/src/mbgl/renderer/buckets/circle_bucket.cpp +++ b/src/mbgl/renderer/buckets/circle_bucket.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -36,7 +35,7 @@ bool CircleBucket::hasData() const { template static float get(const CirclePaintProperties::PossiblyEvaluated& evaluated, const std::string& id, - const std::map& paintPropertyBinders) { + const std::map& paintPropertyBinders) { auto it = paintPropertyBinders.find(id); if (it == paintPropertyBinders.end() || !it->second.statistics().max()) { return evaluated.get().constantOr(Property::defaultValue()); diff --git a/src/mbgl/renderer/buckets/circle_bucket.hpp b/src/mbgl/renderer/buckets/circle_bucket.hpp index 9fc5eb954..4c351a102 100644 --- a/src/mbgl/renderer/buckets/circle_bucket.hpp +++ b/src/mbgl/renderer/buckets/circle_bucket.hpp @@ -1,18 +1,21 @@ #pragma once #include +#include #include #include #include #include #include -#include #include namespace mbgl { class BucketParameters; +using CircleBinders = PaintPropertyBinders; +using CircleLayoutVertex = gfx::Vertex>; + class CircleBucket final : public Bucket { public: using PossiblyEvaluatedLayoutProperties = style::CircleLayoutProperties::PossiblyEvaluated; @@ -30,6 +33,17 @@ public: void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override; + /* + * @param {number} x vertex position + * @param {number} y vertex position + * @param {number} ex extrude normal + * @param {number} ey extrude normal + */ + static CircleLayoutVertex vertex(Point p, float ex, float ey) { + return CircleLayoutVertex{ + {{static_cast((p.x * 2) + ((ex + 1) / 2)), static_cast((p.y * 2) + ((ey + 1) / 2))}}}; + } + using VertexVector = gfx::VertexVector; const std::shared_ptr sharedVertices = std::make_shared(); VertexVector& vertices = *sharedVertices; @@ -38,9 +52,9 @@ public: const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& triangles = *sharedTriangles; - SegmentVector segments; + SegmentVector segments; - std::map paintPropertyBinders; + std::map paintPropertyBinders; const MapMode mode; }; diff --git a/src/mbgl/renderer/buckets/debug_bucket.cpp b/src/mbgl/renderer/buckets/debug_bucket.cpp index 6d96abf58..f2b8f3797 100644 --- a/src/mbgl/renderer/buckets/debug_bucket.cpp +++ b/src/mbgl/renderer/buckets/debug_bucket.cpp @@ -33,7 +33,7 @@ DebugBucket::DebugBucket(const OverscaledTileID& id, Point p{int16_t(::round(left + glyph.data[j] * scale)), int16_t(::round(baseline - glyph.data[j + 1] * scale))}; - vertices.emplace_back(FillProgram::layoutVertex(p)); + vertices.emplace_back(FillBucket::layoutVertex(p)); if (prev) { indices.emplace_back(static_cast(vertices.elements() - 2), diff --git a/src/mbgl/renderer/buckets/debug_bucket.hpp b/src/mbgl/renderer/buckets/debug_bucket.hpp index c70148b7a..c9a4e0305 100644 --- a/src/mbgl/renderer/buckets/debug_bucket.hpp +++ b/src/mbgl/renderer/buckets/debug_bucket.hpp @@ -6,13 +6,16 @@ #include #include #include -#include -#include +#include +#include +#include namespace mbgl { class OverscaledTileID; +using DebugLayoutVertex = gfx::Vertex>; + class DebugBucket : private util::noncopyable { public: DebugBucket(const OverscaledTileID& id, @@ -33,8 +36,8 @@ public: gfx::VertexVector vertices; gfx::IndexVector indices; - SegmentVector segments; - SegmentVector tileBorderSegments; + SegmentVector segments; + SegmentVector tileBorderSegments; std::optional> vertexBuffer; std::optional indexBuffer; std::optional texture; diff --git a/src/mbgl/renderer/buckets/fill_bucket.cpp b/src/mbgl/renderer/buckets/fill_bucket.cpp index a3352a9f7..f9ec9d64d 100644 --- a/src/mbgl/renderer/buckets/fill_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_bucket.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/src/mbgl/renderer/buckets/fill_bucket.hpp b/src/mbgl/renderer/buckets/fill_bucket.hpp index 92d332ffb..f2ea405a5 100644 --- a/src/mbgl/renderer/buckets/fill_bucket.hpp +++ b/src/mbgl/renderer/buckets/fill_bucket.hpp @@ -1,11 +1,11 @@ #pragma once #include +#include #include #include #include #include -#include #include /** @@ -16,7 +16,7 @@ #define MLN_TRIANGULATE_FILL_OUTLINES (MLN_RENDER_BACKEND_METAL) #if MLN_TRIANGULATE_FILL_OUTLINES -#include +#include #endif namespace mbgl { @@ -24,6 +24,9 @@ namespace mbgl { class BucketParameters; class RenderFillLayer; +using FillBinders = PaintPropertyBinders; +using FillLayoutVertex = gfx::Vertex>; + class FillBucket final : public Bucket { public: ~FillBucket() override; @@ -49,6 +52,8 @@ public: void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override; + static FillLayoutVertex layoutVertex(Point p) { return FillLayoutVertex{{{p.x, p.y}}}; } + #if MLN_TRIANGULATE_FILL_OUTLINES using LineVertexVector = gfx::VertexVector; const std::shared_ptr sharedLineVertices = std::make_shared(); @@ -58,14 +63,14 @@ public: const std::shared_ptr sharedLineIndexes = std::make_shared(); LineIndexVector& lineIndexes = *sharedLineIndexes; - SegmentVector lineSegments; + SegmentVector lineSegments; #endif // MLN_TRIANGULATE_FILL_OUTLINES using BasicLineIndexVector = gfx::IndexVector; const std::shared_ptr sharedBasicLineIndexes = std::make_shared(); BasicLineIndexVector& basicLines = *sharedBasicLineIndexes; - SegmentVector basicLineSegments; + SegmentVector basicLineSegments; using VertexVector = gfx::VertexVector; const std::shared_ptr sharedVertices = std::make_shared(); @@ -75,9 +80,9 @@ public: const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& triangles = *sharedTriangles; - SegmentVector triangleSegments; + SegmentVector triangleSegments; - std::map paintPropertyBinders; + std::map paintPropertyBinders; }; } // namespace mbgl diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp index 58587c8d6..535abc8f1 100644 --- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp @@ -1,8 +1,8 @@ #include -#include #include #include #include +#include #include #include @@ -102,7 +102,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, const auto& p1 = ring[i]; vertices.emplace_back( - FillExtrusionProgram::layoutVertex(p1, 0, 0, 1, 1, static_cast(edgeDistance))); + FillExtrusionBucket::layoutVertex(p1, 0, 0, 1, 1, static_cast(edgeDistance))); flatIndices.emplace_back(triangleIndex); triangleIndex++; @@ -118,16 +118,16 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, edgeDistance = 0; } - vertices.emplace_back(FillExtrusionProgram::layoutVertex( + vertices.emplace_back(FillExtrusionBucket::layoutVertex( p1, perp.x, perp.y, 0, 0, static_cast(edgeDistance))); - vertices.emplace_back(FillExtrusionProgram::layoutVertex( + vertices.emplace_back(FillExtrusionBucket::layoutVertex( p1, perp.x, perp.y, 0, 1, static_cast(edgeDistance))); edgeDistance += dist; - vertices.emplace_back(FillExtrusionProgram::layoutVertex( + vertices.emplace_back(FillExtrusionBucket::layoutVertex( p2, perp.x, perp.y, 0, 0, static_cast(edgeDistance))); - vertices.emplace_back(FillExtrusionProgram::layoutVertex( + vertices.emplace_back(FillExtrusionBucket::layoutVertex( p2, perp.x, perp.y, 0, 1, static_cast(edgeDistance))); // ┌──────┐ @@ -198,4 +198,24 @@ void FillExtrusionBucket::update(const FeatureStates& states, } } +std::array FillExtrusionBucket::lightColor(const EvaluatedLight& light) { + const auto color = light.get(); + return {{color.r, color.g, color.b}}; +} + +std::array FillExtrusionBucket::lightPosition(const EvaluatedLight& light, const TransformState& state) { + auto lightPos = light.get().getCartesian(); + mat3 lightMat; + matrix::identity(lightMat); + if (light.get() == LightAnchorType::Viewport) { + matrix::rotate(lightMat, lightMat, -state.getBearing()); + } + matrix::transformMat3f(lightPos, lightPos, lightMat); + return lightPos; +} + +float FillExtrusionBucket::lightIntensity(const EvaluatedLight& light) { + return light.get(); +} + } // namespace mbgl diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp index a430d1ff5..0c7ee70ea 100644 --- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp +++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp @@ -1,11 +1,12 @@ #pragma once #include +#include +#include #include #include #include #include -#include #include namespace mbgl { @@ -13,6 +14,9 @@ namespace mbgl { class BucketParameters; class RenderFillExtrusionLayer; +using FillExtrusionBinders = PaintPropertyBinders; +using FillExtrusionLayoutVertex = gfx::Vertex>; + class FillExtrusionBucket final : public Bucket { public: ~FillExtrusionBucket() override; @@ -39,6 +43,25 @@ public: void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override; + static FillExtrusionLayoutVertex layoutVertex( + Point p, double nx, double ny, double nz, unsigned short t, uint16_t e) { + const auto factor = pow(2, 13); + + return FillExtrusionLayoutVertex{{{p.x, p.y}}, + {{// Multiply normal vector components by 2^13 to pack them into + // integers We pack a bool (`t`) into the x component indicating + // whether it is an upper or lower vertex + static_cast(floor(nx * factor) * 2 + t), + static_cast(ny * factor * 2), + static_cast(nz * factor * 2), + // The edgedistance attribute is used for wrapping fill_extrusion patterns + static_cast(e)}}}; + } + + static std::array lightColor(const EvaluatedLight&); + static std::array lightPosition(const EvaluatedLight&, const TransformState&); + static float lightIntensity(const EvaluatedLight&); + using VertexVector = gfx::VertexVector; const std::shared_ptr sharedVertices = std::make_shared(); VertexVector& vertices = *sharedVertices; @@ -47,9 +70,9 @@ public: const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& triangles = *sharedTriangles; - SegmentVector triangleSegments; + SegmentVector triangleSegments; - std::unordered_map paintPropertyBinders; + std::unordered_map paintPropertyBinders; }; } // namespace mbgl diff --git a/src/mbgl/renderer/buckets/heatmap_bucket.cpp b/src/mbgl/renderer/buckets/heatmap_bucket.cpp index 23b39b302..5b1473247 100644 --- a/src/mbgl/renderer/buckets/heatmap_bucket.cpp +++ b/src/mbgl/renderer/buckets/heatmap_bucket.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -66,10 +65,10 @@ void HeatmapBucket::addFeature(const GeometryTileFeature& feature, // │ 1 2 │ // └─────────┘ // - vertices.emplace_back(HeatmapProgram::vertex(point, -1, -1)); // 1 - vertices.emplace_back(HeatmapProgram::vertex(point, 1, -1)); // 2 - vertices.emplace_back(HeatmapProgram::vertex(point, 1, 1)); // 3 - vertices.emplace_back(HeatmapProgram::vertex(point, -1, 1)); // 4 + vertices.emplace_back(HeatmapBucket::vertex(point, -1, -1)); // 1 + vertices.emplace_back(HeatmapBucket::vertex(point, 1, -1)); // 2 + vertices.emplace_back(HeatmapBucket::vertex(point, 1, 1)); // 3 + vertices.emplace_back(HeatmapBucket::vertex(point, -1, 1)); // 4 auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); diff --git a/src/mbgl/renderer/buckets/heatmap_bucket.hpp b/src/mbgl/renderer/buckets/heatmap_bucket.hpp index 4f911a479..a3ad9fe86 100644 --- a/src/mbgl/renderer/buckets/heatmap_bucket.hpp +++ b/src/mbgl/renderer/buckets/heatmap_bucket.hpp @@ -1,18 +1,22 @@ #pragma once #include +#include #include #include #include #include #include -#include #include namespace mbgl { class BucketParameters; +using HeatmapBinders = PaintPropertyBinders; +using HeatmapLayoutVertex = gfx::Vertex>; +using HeatmapTextureLayoutVertex = gfx::Vertex>; + class HeatmapBucket final : public Bucket { public: HeatmapBucket(const BucketParameters&, const std::vector>&); @@ -30,6 +34,21 @@ public: float getQueryRadius(const RenderLayer&) const override; + /* + * @param {number} x vertex position + * @param {number} y vertex position + * @param {number} ex extrude normal + * @param {number} ey extrude normal + */ + static HeatmapLayoutVertex vertex(Point p, float ex, float ey) { + return HeatmapLayoutVertex{ + {{static_cast((p.x * 2) + ((ex + 1) / 2)), static_cast((p.y * 2) + ((ey + 1) / 2))}}}; + } + + static HeatmapTextureLayoutVertex textureVertex(Point p) { + return HeatmapTextureLayoutVertex{{{p.x, p.y}}}; + } + using VertexVector = gfx::VertexVector; const std::shared_ptr sharedVertices = std::make_shared(); VertexVector& vertices = *sharedVertices; @@ -38,9 +57,9 @@ public: const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& triangles = *sharedTriangles; - SegmentVector segments; + SegmentVector segments; - std::map paintPropertyBinders; + std::map paintPropertyBinders; const MapMode mode; }; diff --git a/src/mbgl/renderer/buckets/hillshade_bucket.cpp b/src/mbgl/renderer/buckets/hillshade_bucket.cpp index 482d72264..8a653c20b 100644 --- a/src/mbgl/renderer/buckets/hillshade_bucket.cpp +++ b/src/mbgl/renderer/buckets/hillshade_bucket.cpp @@ -1,7 +1,5 @@ #include #include -#include -#include #include namespace mbgl { @@ -80,13 +78,13 @@ void HillshadeBucket::setMask(TileMask&& mask_) { segments.emplace_back(vertices.elements(), indices.elements()); } - vertices.emplace_back(HillshadeProgram::layoutVertex( + vertices.emplace_back(HillshadeBucket::layoutVertex( {tlVertex.x, tlVertex.y}, {static_cast(tlVertex.x), static_cast(tlVertex.y)})); - vertices.emplace_back(HillshadeProgram::layoutVertex( + vertices.emplace_back(HillshadeBucket::layoutVertex( {brVertex.x, tlVertex.y}, {static_cast(brVertex.x), static_cast(tlVertex.y)})); - vertices.emplace_back(HillshadeProgram::layoutVertex( + vertices.emplace_back(HillshadeBucket::layoutVertex( {tlVertex.x, brVertex.y}, {static_cast(tlVertex.x), static_cast(brVertex.y)})); - vertices.emplace_back(HillshadeProgram::layoutVertex( + vertices.emplace_back(HillshadeBucket::layoutVertex( {brVertex.x, brVertex.y}, {static_cast(brVertex.x), static_cast(brVertex.y)})); auto& segment = segments.back(); diff --git a/src/mbgl/renderer/buckets/hillshade_bucket.hpp b/src/mbgl/renderer/buckets/hillshade_bucket.hpp index 1d46442c5..a6413becc 100644 --- a/src/mbgl/renderer/buckets/hillshade_bucket.hpp +++ b/src/mbgl/renderer/buckets/hillshade_bucket.hpp @@ -1,19 +1,23 @@ #pragma once #include +#include #include #include -#include -#include +#include +#include #include #include -#include +#include #include #include #include namespace mbgl { +using HillshadeBinders = PaintPropertyBinders; +using HillshadeLayoutVertex = gfx::Vertex>; + class HillshadeBucket final : public Bucket { public: HillshadeBucket(PremultipliedImage&&, Tileset::DEMEncoding encoding); @@ -42,6 +46,10 @@ public: void setPrepared(bool preparedState) { prepared = preparedState; } + static HillshadeLayoutVertex layoutVertex(Point p, Point t) { + return HillshadeLayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}}; + } + // Raster-DEM Tile Sources use the default buffers from Painter using VertexVector = gfx::VertexVector; std::shared_ptr sharedVertices = std::make_shared(); @@ -51,7 +59,7 @@ public: std::shared_ptr sharedIndices = std::make_shared(); IndexVector& indices = *sharedIndices; - SegmentVector segments; + SegmentVector segments; private: DEMData demdata; diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp index 3adb72323..2ae782ea7 100644 --- a/src/mbgl/renderer/buckets/line_bucket.cpp +++ b/src/mbgl/renderer/buckets/line_bucket.cpp @@ -54,14 +54,14 @@ void LineBucket::addFeature(const GeometryTileFeature& feature, void LineBucket::addGeometry(const GeometryCoordinates& coordinates, const GeometryTileFeature& feature, const CanonicalTileID& canonical) { - gfx::PolylineGenerator> generator( + gfx::PolylineGenerator generator( vertices, - LineProgram::layoutVertex, + LineBucket::layoutVertex, segments, - [](std::size_t vertexOffset, std::size_t indexOffset) -> Segment { - return Segment(vertexOffset, indexOffset); + [](std::size_t vertexOffset, std::size_t indexOffset) -> SegmentBase { + return SegmentBase(vertexOffset, indexOffset); }, - [](auto& seg) -> Segment& { return seg; }, + [](auto& seg) -> SegmentBase& { return seg; }, triangles); gfx::PolylineGeneratorOptions options; @@ -137,7 +137,7 @@ bool LineBucket::hasData() const { template static float get(const LinePaintProperties::PossiblyEvaluated& evaluated, const std::string& id, - const std::map& paintPropertyBinders) { + const std::map& paintPropertyBinders) { auto it = paintPropertyBinders.find(id); if (it == paintPropertyBinders.end() || !it->second.statistics().max()) { return evaluated.get().constantOr(Property::defaultValue()); diff --git a/src/mbgl/renderer/buckets/line_bucket.hpp b/src/mbgl/renderer/buckets/line_bucket.hpp index c2630d0f1..b72dbfa93 100644 --- a/src/mbgl/renderer/buckets/line_bucket.hpp +++ b/src/mbgl/renderer/buckets/line_bucket.hpp @@ -1,10 +1,10 @@ #pragma once #include +#include #include #include #include #include -#include #include #include @@ -13,6 +13,9 @@ namespace mbgl { class BucketParameters; class RenderLineLayer; +using LineBinders = PaintPropertyBinders; +using LineLayoutVertex = gfx::Vertex>>; + class LineBucket final : public Bucket { public: using PossiblyEvaluatedLayoutProperties = style::LineLayoutProperties::PossiblyEvaluated; @@ -38,6 +41,46 @@ public: void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override; + /* + * @param p vertex position + * @param e extrude normal + * @param round whether the vertex uses a round line cap + * @param up whether the line normal points up or down + * @param dir direction of the line cap (-1/0/1) + */ + static LineLayoutVertex layoutVertex( + Point p, Point e, bool round, bool up, int8_t dir, int32_t linesofar = 0) { + return LineLayoutVertex{ + {{static_cast((p.x * 2) | (round ? 1 : 0)), static_cast((p.y * 2) | (up ? 1 : 0))}}, + {{// add 128 to store a byte in an unsigned byte + static_cast(util::clamp(::round(extrudeScale * e.x) + 128, 0., 255.)), + static_cast(util::clamp(::round(extrudeScale * e.y) + 128, 0., 255.)), + + // Encode the -1/0/1 direction value into the first two bits of .z + // of a_data. Combine it with the lower 6 bits of `linesofar` + // (shifted by 2 bites to make room for the direction value). The + // upper 8 bits of `linesofar` are placed in the `w` component. + // `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that we + // can store longer distances while sacrificing precision. + + // Encode the -1/0/1 direction value into .zw coordinates of + // a_data, which is normally covered by linesofar, so we need to + // merge them. The z component's first bit, as well as the sign + // bit is reserved for the direction, so we need to shift the + // linesofar. + static_cast(((dir == 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofar & 0x3F) << 2)), + static_cast(linesofar >> 6)}}}; + } + + /* + * Scale the extrusion vector so that the normal length is this value. + * Contains the "texture" normals (-1..1). This is distinct from the extrude + * normals for line joins, because the x-value remains 0 for the texture + * normal array, while the extrude normal actually moves the vertex to + * create the acute/bevelled line join. + */ + static const int8_t extrudeScale = 63; + PossiblyEvaluatedLayoutProperties layout; using VertexVector = gfx::VertexVector; @@ -48,9 +91,9 @@ public: const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& triangles = *sharedTriangles; - SegmentVector segments; + SegmentVector segments; - std::map paintPropertyBinders; + std::map paintPropertyBinders; private: void addGeometry(const GeometryCoordinates&, const GeometryTileFeature&, const CanonicalTileID&); diff --git a/src/mbgl/renderer/buckets/raster_bucket.cpp b/src/mbgl/renderer/buckets/raster_bucket.cpp index ba9bcad9b..d139c98cc 100644 --- a/src/mbgl/renderer/buckets/raster_bucket.cpp +++ b/src/mbgl/renderer/buckets/raster_bucket.cpp @@ -1,6 +1,5 @@ #include #include -#include #include namespace mbgl { @@ -78,13 +77,13 @@ void RasterBucket::setMask(TileMask&& mask_) { segments.emplace_back(vertices.elements(), indices.elements()); } - vertices.emplace_back(RasterProgram::layoutVertex( + vertices.emplace_back(RasterBucket::layoutVertex( {tlVertex.x, tlVertex.y}, {static_cast(tlVertex.x), static_cast(tlVertex.y)})); - vertices.emplace_back(RasterProgram::layoutVertex( + vertices.emplace_back(RasterBucket::layoutVertex( {brVertex.x, tlVertex.y}, {static_cast(brVertex.x), static_cast(tlVertex.y)})); - vertices.emplace_back(RasterProgram::layoutVertex( + vertices.emplace_back(RasterBucket::layoutVertex( {tlVertex.x, brVertex.y}, {static_cast(tlVertex.x), static_cast(brVertex.y)})); - vertices.emplace_back(RasterProgram::layoutVertex( + vertices.emplace_back(RasterBucket::layoutVertex( {brVertex.x, brVertex.y}, {static_cast(brVertex.x), static_cast(brVertex.y)})); auto& segment = segments.back(); diff --git a/src/mbgl/renderer/buckets/raster_bucket.hpp b/src/mbgl/renderer/buckets/raster_bucket.hpp index e3e81f92a..8e14507e3 100644 --- a/src/mbgl/renderer/buckets/raster_bucket.hpp +++ b/src/mbgl/renderer/buckets/raster_bucket.hpp @@ -3,9 +3,11 @@ #include #include #include -#include +#include #include +#include #include +#include #include #include @@ -19,6 +21,9 @@ class Texture2D; using Texture2DPtr = std::shared_ptr; } // namespace gfx +using RasterBinders = PaintPropertyBinders; +using RasterLayoutVertex = gfx::Vertex>; + class RasterBucket final : public Bucket { public: RasterBucket(PremultipliedImage&&); @@ -32,6 +37,10 @@ public: void setImage(std::shared_ptr); void setMask(TileMask&&); + static RasterLayoutVertex layoutVertex(Point p, Point t) { + return RasterLayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}}; + } + std::shared_ptr image; std::optional texture; gfx::Texture2DPtr texture2d; @@ -47,7 +56,7 @@ public: const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& indices = *sharedTriangles; - SegmentVector segments; + SegmentVector segments; }; } // namespace mbgl diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index adc616931..b21036c49 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -15,6 +15,27 @@ namespace { std::atomic maxBucketInstanceId; } // namespace +std::unique_ptr SymbolSizeBinder::create(const float tileZoom, + const style::PropertyValue& sizeProperty, + const float defaultValue) { + return sizeProperty.match( + [&](const Undefined& value) -> std::unique_ptr { + return std::make_unique(tileZoom, value, defaultValue); + }, + [&](float value) -> std::unique_ptr { + return std::make_unique(tileZoom, value, defaultValue); + }, + [&](const style::PropertyExpression& expression) -> std::unique_ptr { + if (expression.isFeatureConstant()) { + return std::make_unique(tileZoom, expression, defaultValue); + } else if (expression.isZoomConstant()) { + return std::make_unique(tileZoom, expression, defaultValue); + } else { + return std::make_unique(tileZoom, expression, defaultValue); + } + }); +} + SymbolBucket::SymbolBucket(Immutable layout_, const std::map>& paintProperties_, const style::PropertyValue& textSize, diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index eff8c3108..88a0a73ea 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -5,13 +5,12 @@ #include #include #include -#include #include -#include #include +#include +#include #include #include -#include #include #include @@ -20,6 +19,162 @@ namespace mbgl { class CrossTileSymbolLayerIndex; +using SymbolIconBinders = PaintPropertyBinders; +using SymbolTextBinders = PaintPropertyBinders; +using SymbolLayoutVertex = + gfx::Vertex, attributes::pixeloffset>>; +using SymbolDynamicLayoutAttributes = TypeList; +using SymbolOpacityAttributes = TypeList; + +using CollisionBoxLayoutAttributes = TypeList; +using CollisionBoxDynamicAttributes = TypeList; + +const uint16_t MAX_GLYPH_ICON_SIZE = 255; +const uint16_t SIZE_PACK_FACTOR = 128; +const uint16_t MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR; + +struct ZoomEvaluatedSize { + bool isZoomConstant; + bool isFeatureConstant; + float sizeT; + float size; + float layoutSize; +}; +// Mimic the PaintPropertyBinder technique specifically for the {text,icon}-size +// layout properties in order to provide a 'custom' scheme for encoding the +// necessary attribute data. As with PaintPropertyBinder, SymbolSizeBinder is +// an abstract class whose implementations handle the particular attribute & +// uniform logic needed by each possible type of the {Text,Icon}Size properties. +class SymbolSizeBinder { +public: + virtual ~SymbolSizeBinder() = default; + + // using UniformList = TypeList; using UniformValues = gfx::UniformValues; + + static std::unique_ptr create(float tileZoom, + const style::PropertyValue& sizeProperty, + float defaultValue); + + virtual Range getVertexSizeData(const GeometryTileFeature& feature) = 0; + virtual ZoomEvaluatedSize evaluateForZoom(float currentZoom) const = 0; + + /*UniformValues uniformValues(float currentZoom) const { + const ZoomEvaluatedSize u = evaluateForZoom(currentZoom); + return UniformValues{uniforms::is_size_zoom_constant::Value(u.isZoomConstant), + uniforms::is_size_feature_constant::Value(u.isFeatureConstant), + uniforms::size_t::Value(u.sizeT), + uniforms::size::Value(u.size)}; + }*/ +}; + +class ConstantSymbolSizeBinder final : public SymbolSizeBinder { +public: + ConstantSymbolSizeBinder(const float /*tileZoom*/, const float& size, const float /*defaultValue*/) noexcept + : layoutSize(size) {} + + ConstantSymbolSizeBinder(const float /*tileZoom*/, const style::Undefined&, const float defaultValue) noexcept + : layoutSize(defaultValue) {} + + ConstantSymbolSizeBinder(const float tileZoom, + const style::PropertyExpression& expression_, + const float /*defaultValue*/ + ) + : layoutSize(expression_.evaluate(tileZoom + 1)), + expression(expression_) { + const Range zoomLevels = expression_.getCoveringStops(tileZoom, tileZoom + 1); + coveringRanges = std::make_tuple( + zoomLevels, Range{expression_.evaluate(zoomLevels.min), expression_.evaluate(zoomLevels.max)}); + } + + Range getVertexSizeData(const GeometryTileFeature&) noexcept override { return {0.0f, 0.0f}; }; + + ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override { + float size = layoutSize; + bool isZoomConstant = !(coveringRanges || expression); + if (coveringRanges) { + // Even though we could get the exact value of the camera function + // at z = currentZoom, we intentionally do not: instead, we + // interpolate between the camera function values at a pair of zoom + // stops covering [tileZoom, tileZoom + 1] in order to be consistent + // with this restriction on composite functions. + const Range& zoomLevels = std::get<0>(*coveringRanges); + const Range& sizeLevels = std::get<1>(*coveringRanges); + float t = util::clamp(expression->interpolationFactor(zoomLevels, currentZoom), 0.0f, 1.0f); + size = sizeLevels.min + t * (sizeLevels.max - sizeLevels.min); + } else if (expression) { + size = expression->evaluate(currentZoom); + } + + const float unused = 0.0f; + return {.isZoomConstant = isZoomConstant, + .isFeatureConstant = true, + .sizeT = unused, + .size = size, + .layoutSize = layoutSize}; + } + + float layoutSize; + std::optional, Range>> coveringRanges; + std::optional> expression; +}; + +class SourceFunctionSymbolSizeBinder final : public SymbolSizeBinder { +public: + SourceFunctionSymbolSizeBinder(const float /*tileZoom*/, + style::PropertyExpression expression_, + const float defaultValue_) noexcept + : expression(std::move(expression_)), + defaultValue(defaultValue_) {} + + Range getVertexSizeData(const GeometryTileFeature& feature) override { + const float size = expression.evaluate(feature, defaultValue); + return {size, size}; + }; + + ZoomEvaluatedSize evaluateForZoom(float) const noexcept override { + const float unused = 0.0f; + return { + .isZoomConstant = true, .isFeatureConstant = false, .sizeT = unused, .size = unused, .layoutSize = unused}; + } + + style::PropertyExpression expression; + const float defaultValue; +}; + +class CompositeFunctionSymbolSizeBinder final : public SymbolSizeBinder { +public: + CompositeFunctionSymbolSizeBinder(const float tileZoom, + style::PropertyExpression expression_, + const float defaultValue_) noexcept + : expression(std::move(expression_)), + defaultValue(defaultValue_), + layoutZoom(tileZoom + 1), + coveringZoomStops(expression.getCoveringStops(tileZoom, tileZoom + 1)) {} + + Range getVertexSizeData(const GeometryTileFeature& feature) override { + return {expression.evaluate(coveringZoomStops.min, feature, defaultValue), + expression.evaluate(coveringZoomStops.max, feature, defaultValue)}; + }; + + ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override { + float sizeInterpolationT = util::clamp( + expression.interpolationFactor(coveringZoomStops, currentZoom), 0.0f, 1.0f); + + const float unused = 0.0f; + return {.isZoomConstant = false, + .isFeatureConstant = false, + .sizeT = sizeInterpolationT, + .size = unused, + .layoutSize = unused}; + } + + style::PropertyExpression expression; + const float defaultValue; + float layoutZoom; + Range coveringZoomStops; +}; + class PlacedSymbol { public: PlacedSymbol(Point anchorPoint_, @@ -110,6 +265,42 @@ public: bool check(std::source_location) override; #endif + static SymbolLayoutVertex layoutVertex(Point labelAnchor, + Point o, + float glyphOffsetY, + uint16_t tx, + uint16_t ty, + const Range& sizeData, + bool isSDF, + Point pixelOffset, + Point minFontScale) { + const uint16_t aSizeMin = (std::min(MAX_PACKED_SIZE, static_cast(sizeData.min * SIZE_PACK_FACTOR)) + << 1) + + uint16_t(isSDF); + const uint16_t aSizeMax = std::min(MAX_PACKED_SIZE, static_cast(sizeData.max * SIZE_PACK_FACTOR)); + return { + // combining pos and offset to reduce number of vertex attributes + // passed to shader (8 max for some devices) + {{static_cast(labelAnchor.x), + static_cast(labelAnchor.y), + static_cast(std::round(o.x * 32)), // use 1/32 pixels for placement + static_cast(std::round((o.y + glyphOffsetY) * 32))}}, + {{tx, ty, aSizeMin, aSizeMax}}, + {{static_cast(pixelOffset.x * 16), + static_cast(pixelOffset.y * 16), + static_cast(minFontScale.x * 256), + static_cast(minFontScale.y * 256)}}, + }; + } + + static gfx::Vertex dynamicLayoutVertex(Point anchorPoint, float labelAngle) { + return {{{anchorPoint.x, anchorPoint.y, labelAngle}}}; + } + + static gfx::Vertex opacityVertex(bool placed, float opacity) { + return {{{static_cast((static_cast(opacity * 127) << 1) | static_cast(placed))}}}; + } + Immutable layout; const std::string bucketLeaderID; float sortedAngle = std::numeric_limits::max(); @@ -131,8 +322,8 @@ public: const std::vector sortKeyRanges; struct PaintProperties { - SymbolIconProgram::Binders iconBinders; - SymbolSDFTextProgram::Binders textBinders; + SymbolIconBinders iconBinders; + SymbolTextBinders textBinders; }; std::map paintProperties; @@ -180,7 +371,7 @@ public: const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& triangles = *sharedTriangles; - SegmentVector segments; + SegmentVector segments; std::vector placedSymbols; } text; @@ -202,7 +393,7 @@ public: CollisionDynamicVertexVector& dynamicVertices() { return *sharedDynamicVertices; } const CollisionDynamicVertexVector& dynamicVertices() const { return *sharedDynamicVertices; } - SegmentVector segments; + SegmentVector segments; }; struct CollisionBoxBuffer : public CollisionBuffer { @@ -241,6 +432,20 @@ public: return *textCollisionCircle; } + static gfx::Vertex collisionLayoutVertex(Point a, + Point anchor, + Point o) { + return {{{static_cast(a.x), static_cast(a.y)}}, + {{static_cast(anchor.x), static_cast(anchor.y)}}, + {{static_cast(::round(o.x)), static_cast(::round(o.y))}}}; + } + + static gfx::Vertex collisionDynamicVertex(bool placed, + bool notUsed, + Point shift) { + return {{{static_cast(placed), static_cast(notUsed)}}, {{shift.x, shift.y}}}; + } + const float tilePixelRatio; uint32_t bucketInstanceId; const bool allowVerticalPlacement; diff --git a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp index 80d94fdf0..1da8d75de 100644 --- a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -70,7 +70,7 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete } const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped(); - auto* binders = static_cast(drawable.getBinders()); + auto* binders = static_cast(drawable.getBinders()); if (!binders) { assert(false); return; diff --git a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp index d474e0c3a..2b439c089 100644 --- a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -43,12 +43,12 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP // but the resulting buffer can be shared across all the drawables from the layer. const FillExtrusionPropsUBO propsUBO = { .color = constOrDefault(evaluated), - .light_color = FillExtrusionProgram::lightColor(parameters.evaluatedLight), + .light_color = FillExtrusionBucket::lightColor(parameters.evaluatedLight), .pad1 = 0, - .light_position = FillExtrusionProgram::lightPosition(parameters.evaluatedLight, state), + .light_position = FillExtrusionBucket::lightPosition(parameters.evaluatedLight, state), .base = constOrDefault(evaluated), .height = constOrDefault(evaluated), - .light_intensity = FillExtrusionProgram::lightIntensity(parameters.evaluatedLight), + .light_intensity = FillExtrusionBucket::lightIntensity(parameters.evaluatedLight), .vertical_gradient = evaluated.get() ? 1.0f : 0.0f, .opacity = evaluated.get(), .fade = crossfade.t, @@ -75,7 +75,7 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP return; } - auto* binders = static_cast(drawable.getBinders()); + auto* binders = static_cast(drawable.getBinders()); const auto* tile = drawable.getRenderTile(); if (!binders || !tile) { assert(false); diff --git a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp index 83979102c..61c6a0863 100644 --- a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp @@ -70,7 +70,7 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped(); - auto* binders = static_cast(drawable.getBinders()); + auto* binders = static_cast(drawable.getBinders()); const auto* tile = drawable.getRenderTile(); if (!binders || !tile) { assert(false); diff --git a/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp b/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp index ed22ad2f6..8c22cb113 100644 --- a/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -58,7 +57,7 @@ void HeatmapLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamet const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped(); - auto* binders = static_cast(drawable.getBinders()); + auto* binders = static_cast(drawable.getBinders()); const auto* tile = drawable.getRenderTile(); if (!binders || !tile) { assert(false); diff --git a/src/mbgl/renderer/layers/line_layer_tweaker.cpp b/src/mbgl/renderer/layers/line_layer_tweaker.cpp index dd9e0a0fb..d09310e4f 100644 --- a/src/mbgl/renderer/layers/line_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/line_layer_tweaker.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -175,7 +175,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped(); - auto* binders = static_cast(drawable.getBinders()); + auto* binders = static_cast(drawable.getBinders()); const auto* tile = drawable.getRenderTile(); if (!binders || !tile) { assert(false); diff --git a/src/mbgl/renderer/layers/render_background_layer.hpp b/src/mbgl/renderer/layers/render_background_layer.hpp index faadd7a39..f3e7bd2bc 100644 --- a/src/mbgl/renderer/layers/render_background_layer.hpp +++ b/src/mbgl/renderer/layers/render_background_layer.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -42,7 +42,7 @@ private: // Paint properties style::BackgroundPaintProperties::Unevaluated unevaluated; - SegmentVector segments; + SegmentVector segments; // Drawable shaders gfx::ShaderProgramBasePtr plainShader; diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index 7ec29289e..4dfd429b7 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index eef29e926..1c2709301 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index 9346e1323..26028b31e 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mbgl/renderer/layers/render_fill_layer.hpp b/src/mbgl/renderer/layers/render_fill_layer.hpp index 1901e7a87..f68cf6924 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_layer.hpp @@ -10,12 +10,6 @@ namespace mbgl { -class FillBucket; -class FillProgram; -class FillPatternProgram; -class FillOutlineProgram; -class FillOutlinePatternProgram; - class FillLayerTweaker; using FillLayerTweakerPtr = std::shared_ptr; diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.hpp b/src/mbgl/renderer/layers/render_heatmap_layer.hpp index 7c03b5055..640ab02bb 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.hpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -62,7 +62,7 @@ private: std::shared_ptr colorRamp; std::unique_ptr renderTexture; std::optional colorRampTexture; - SegmentVector segments; + SegmentVector segments; gfx::ShaderGroupPtr heatmapShaderGroup; gfx::ShaderProgramBasePtr heatmapTextureShader; diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.hpp b/src/mbgl/renderer/layers/render_hillshade_layer.hpp index 28c59cce2..3490788bc 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.hpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.hpp @@ -1,8 +1,7 @@ #pragma once #include -#include -#include +#include #include #include #include diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 86a3f6939..454026466 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index 056b785ff..6846f31c4 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mbgl/renderer/layers/render_raster_layer.hpp b/src/mbgl/renderer/layers/render_raster_layer.hpp index 6d73aa835..fcffd8461 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.hpp +++ b/src/mbgl/renderer/layers/render_raster_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include @@ -9,7 +9,6 @@ namespace mbgl { class ImageSourceRenderData; -class RasterProgram; class RenderRasterLayer final : public RenderLayer { public: @@ -62,7 +61,7 @@ private: using TriangleIndexVectorPtr = std::shared_ptr; TriangleIndexVectorPtr staticDataIndices; - using RasterSegmentVector = SegmentVector; + using RasterSegmentVector = SegmentVector; using RasterSegmentVectorPtr = std::shared_ptr; std::shared_ptr staticDataSegments; }; diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index c7bd608c9..40ec6d7ea 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -2,9 +2,7 @@ #include #include -#include #include -#include #include #include #include @@ -73,8 +71,8 @@ style::SymbolPropertyValues textPropertyValues(const style::SymbolPaintPropertie .hasFill = evaluated_.get().constantOr(Color::black()).a > 0}; } -using SegmentWrapper = std::reference_wrapper>; -using SegmentVectorWrapper = std::reference_wrapper>; +using SegmentWrapper = std::reference_wrapper; +using SegmentVectorWrapper = std::reference_wrapper; using SegmentsWrapper = variant; struct RenderableSegment { @@ -258,7 +256,7 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) { } namespace { -const SegmentVector emptySegmentVector; +const SegmentVector emptySegmentVector; constexpr auto posOffsetAttribName = "a_pos_offset"; void updateTileAttributes(const SymbolBucket::Buffer& buffer, diff --git a/src/mbgl/renderer/layers/render_symbol_layer.hpp b/src/mbgl/renderer/layers/render_symbol_layer.hpp index 592e659c3..1091f7e08 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.hpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.hpp @@ -56,27 +56,10 @@ enum class SymbolType : uint8_t { } // namespace style -class SymbolIconProgram; -class SymbolSDFIconProgram; -class SymbolSDFTextProgram; -class SymbolTextAndIconProgram; -class CollisionBoxProgram; -class CollisionCircleProgram; - class SymbolLayerTweaker; using SymbolLayerTweakerPtr = std::shared_ptr; class RenderSymbolLayer final : public RenderLayer { -public: - struct Programs { - std::shared_ptr symbolIconProgram; - std::shared_ptr symbolSDFIconProgram; - std::shared_ptr symbolSDFTextProgram; - std::shared_ptr symbolTextAndIconProgram; - std::shared_ptr collisionBoxProgram; - std::shared_ptr collisionCircleProgram; - }; - public: explicit RenderSymbolLayer(Immutable); ~RenderSymbolLayer() override; diff --git a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp index 2553b8241..864881718 100644 --- a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -104,8 +103,8 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete const auto& symbolData = static_cast(*drawable.getData()); const auto isText = (symbolData.symbolType == SymbolType::Text); - const auto* textBinders = isText ? static_cast(drawable.getBinders()) : nullptr; - const auto* iconBinders = isText ? nullptr : static_cast(drawable.getBinders()); + const auto* textBinders = isText ? static_cast(drawable.getBinders()) : nullptr; + const auto* iconBinders = isText ? nullptr : static_cast(drawable.getBinders()); const auto bucket = std::static_pointer_cast(drawable.getBucket()); const auto* tile = drawable.getRenderTile(); diff --git a/src/mbgl/renderer/render_static_data.cpp b/src/mbgl/renderer/render_static_data.cpp index 519837736..56f5fdb65 100644 --- a/src/mbgl/renderer/render_static_data.cpp +++ b/src/mbgl/renderer/render_static_data.cpp @@ -33,19 +33,19 @@ gfx::IndexVector RenderStaticData::tileLineStripIndices() { gfx::VertexVector RenderStaticData::rasterVertices() { gfx::VertexVector result; - result.emplace_back(RasterProgram::layoutVertex({0, 0}, {0, 0})); - result.emplace_back(RasterProgram::layoutVertex({util::EXTENT, 0}, {util::EXTENT, 0})); - result.emplace_back(RasterProgram::layoutVertex({0, util::EXTENT}, {0, util::EXTENT})); - result.emplace_back(RasterProgram::layoutVertex({util::EXTENT, util::EXTENT}, {util::EXTENT, util::EXTENT})); + result.emplace_back(RasterBucket::layoutVertex({0, 0}, {0, 0})); + result.emplace_back(RasterBucket::layoutVertex({util::EXTENT, 0}, {util::EXTENT, 0})); + result.emplace_back(RasterBucket::layoutVertex({0, util::EXTENT}, {0, util::EXTENT})); + result.emplace_back(RasterBucket::layoutVertex({util::EXTENT, util::EXTENT}, {util::EXTENT, util::EXTENT})); return result; } gfx::VertexVector RenderStaticData::heatmapTextureVertices() { gfx::VertexVector result; - result.emplace_back(HeatmapTextureProgram::layoutVertex({0, 0})); - result.emplace_back(HeatmapTextureProgram::layoutVertex({1, 0})); - result.emplace_back(HeatmapTextureProgram::layoutVertex({0, 1})); - result.emplace_back(HeatmapTextureProgram::layoutVertex({1, 1})); + result.emplace_back(HeatmapBucket::textureVertex({0, 0})); + result.emplace_back(HeatmapBucket::textureVertex({1, 0})); + result.emplace_back(HeatmapBucket::textureVertex({0, 1})); + result.emplace_back(HeatmapBucket::textureVertex({1, 1})); return result; } @@ -60,26 +60,26 @@ RenderStaticData::RenderStaticData(float pixelRatio, std::unique_ptr RenderStaticData::tileTriangleSegments() { - SegmentVector segments; +SegmentVector RenderStaticData::tileTriangleSegments() { + SegmentVector segments; segments.emplace_back(0, 0, 4, 6); return segments; } -SegmentVector RenderStaticData::tileBorderSegments() { - SegmentVector segments; +SegmentVector RenderStaticData::tileBorderSegments() { + SegmentVector segments; segments.emplace_back(0, 0, 4, 5); return segments; } -SegmentVector RenderStaticData::rasterSegments() { - SegmentVector segments; +SegmentVector RenderStaticData::rasterSegments() { + SegmentVector segments; segments.emplace_back(0, 0, 4, 6); return segments; } -SegmentVector RenderStaticData::heatmapTextureSegments() { - SegmentVector segments; +SegmentVector RenderStaticData::heatmapTextureSegments() { + SegmentVector segments; segments.emplace_back(0, 0, 4, 6); return segments; } diff --git a/src/mbgl/renderer/render_static_data.hpp b/src/mbgl/renderer/render_static_data.hpp index 9e2fb5b6d..bbbf6c88b 100644 --- a/src/mbgl/renderer/render_static_data.hpp +++ b/src/mbgl/renderer/render_static_data.hpp @@ -4,10 +4,9 @@ #include #include #include -#include -#include #include -#include +#include +#include #include #include @@ -37,10 +36,10 @@ public: static gfx::VertexVector rasterVertices(); static gfx::VertexVector heatmapTextureVertices(); - static SegmentVector tileTriangleSegments(); - static SegmentVector tileBorderSegments(); - static SegmentVector rasterSegments(); - static SegmentVector heatmapTextureSegments(); + static SegmentVector tileTriangleSegments(); + static SegmentVector tileBorderSegments(); + static SegmentVector rasterSegments(); + static SegmentVector heatmapTextureSegments(); std::optional> depthRenderbuffer; bool has3D = false; @@ -52,7 +51,7 @@ public: std::unique_ptr shaders; - const SegmentVector clippingMaskSegments; + const SegmentVector clippingMaskSegments; #ifndef NDEBUG Programs overdrawPrograms; diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp index 2797431be..fc842ef87 100644 --- a/src/mbgl/renderer/render_tile.cpp +++ b/src/mbgl/renderer/render_tile.cpp @@ -137,91 +137,6 @@ void RenderTile::prepare(const SourcePrepareParameters& parameters) { matrix::multiply(nearClippedMatrix, transform.nearClippedProjMatrix, nearClippedMatrix); } -void RenderTile::finishRender(PaintParameters& parameters) const { - if (!needsRendering || parameters.debugOptions == MapDebugOptions::NoDebug) return; - - static const style::Properties<>::PossiblyEvaluated properties{}; - static const DebugProgram::Binders paintAttributeData(properties, 0); - - auto program = parameters.shaders.getLegacyGroup().get(); - if (!program) { - return; - } - - if (parameters.debugOptions & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) { - assert(debugBucket); - const auto allAttributeBindings = DebugProgram::computeAllAttributeBindings( - *debugBucket->vertexBuffer, paintAttributeData, properties); - - program->draw(parameters.context, - *parameters.renderPass, - gfx::Lines{4.0f * parameters.pixelRatio}, - gfx::DepthMode::disabled(), - gfx::StencilMode::disabled(), - gfx::ColorMode::unblended(), - gfx::CullFaceMode::disabled(), - *debugBucket->indexBuffer, - debugBucket->segments, - DebugProgram::computeAllUniformValues( - DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix), - uniforms::color::Value(Color::white()), - uniforms::overlay_scale::Value(1.0f)}, - paintAttributeData, - properties, - static_cast(parameters.state.getZoom())), - allAttributeBindings, - DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}}, - "text-outline"); - - program->draw(parameters.context, - *parameters.renderPass, - gfx::Lines{2.0f * parameters.pixelRatio}, - gfx::DepthMode::disabled(), - gfx::StencilMode::disabled(), - gfx::ColorMode::unblended(), - gfx::CullFaceMode::disabled(), - *debugBucket->indexBuffer, - debugBucket->segments, - DebugProgram::computeAllUniformValues( - DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix), - uniforms::color::Value(Color::black()), - uniforms::overlay_scale::Value(1.0f)}, - paintAttributeData, - properties, - static_cast(parameters.state.getZoom())), - allAttributeBindings, - DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}}, - "text"); - } - - if (parameters.debugOptions & MapDebugOptions::TileBorders) { - assert(debugBucket); - if (debugBucket->tileBorderSegments.empty()) { - debugBucket->tileBorderSegments = RenderStaticData::tileBorderSegments(); - } - program->draw(parameters.context, - *parameters.renderPass, - gfx::LineStrip{4.0f * parameters.pixelRatio}, - gfx::DepthMode::disabled(), - gfx::StencilMode::disabled(), - gfx::ColorMode::unblended(), - gfx::CullFaceMode::disabled(), - *parameters.staticData.tileBorderIndexBuffer, - debugBucket->tileBorderSegments, - DebugProgram::computeAllUniformValues( - DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix), - uniforms::color::Value(Color::red()), - uniforms::overlay_scale::Value(1.0f)}, - paintAttributeData, - properties, - static_cast(parameters.state.getZoom())), - DebugProgram::computeAllAttributeBindings( - *parameters.staticData.tileVertexBuffer, paintAttributeData, properties), - DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}}, - "border"); - } -} - void RenderTile::setFeatureState(const LayerFeatureStates& states) { tile.setFeatureState(states); } diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp index 778eba384..5fd313576 100644 --- a/src/mbgl/renderer/render_tile.hpp +++ b/src/mbgl/renderer/render_tile.hpp @@ -66,7 +66,6 @@ public: void upload(gfx::UploadPass&) const; void prepare(const SourcePrepareParameters&); - void finishRender(PaintParameters&) const; static mat4 translateVtxMatrix(const UnwrappedTileID& id, const mat4& tileMatrix, diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp index 902719f05..b8d46892d 100644 --- a/src/mbgl/renderer/sources/render_image_source.cpp +++ b/src/mbgl/renderer/sources/render_image_source.cpp @@ -26,43 +26,6 @@ void ImageSourceRenderData::upload(gfx::UploadPass& uploadPass) const { } } -void ImageSourceRenderData::render(PaintParameters& parameters) const { - if (!bucket || !(parameters.debugOptions & MapDebugOptions::TileBorders)) { - return; - } - assert(debugTexture); - static const style::Properties<>::PossiblyEvaluated properties{}; - static const DebugProgram::Binders paintAttributeData(properties, 0); - - auto programInstance = parameters.shaders.getLegacyGroup().get(); - if (!programInstance) { - return; - } - - for (auto matrix : matrices) { - programInstance->draw(parameters.context, - *parameters.renderPass, - gfx::LineStrip{4.0f * parameters.pixelRatio}, - gfx::DepthMode::disabled(), - gfx::StencilMode::disabled(), - gfx::ColorMode::unblended(), - gfx::CullFaceMode::disabled(), - *parameters.staticData.tileBorderIndexBuffer, - RenderStaticData::tileBorderSegments(), - DebugProgram::computeAllUniformValues( - DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix), - uniforms::color::Value(Color::red()), - uniforms::overlay_scale::Value(1.0f)}, - paintAttributeData, - properties, - static_cast(parameters.state.getZoom())), - DebugProgram::computeAllAttributeBindings( - *parameters.staticData.tileVertexBuffer, paintAttributeData, properties), - DebugProgram::TextureBindings{textures::image::Value{debugTexture->getResource()}}, - "image"); - } -} - RenderImageSource::RenderImageSource(Immutable impl_) : RenderSource(std::move(impl_)) {} @@ -207,11 +170,11 @@ void RenderImageSource::update(Immutable baseImpl_, } // Set Bucket Vertices, Indices, and segments - bucket->vertices.emplace_back(RasterProgram::layoutVertex({geomCoords[0].x, geomCoords[0].y}, {0, 0})); - bucket->vertices.emplace_back(RasterProgram::layoutVertex({geomCoords[1].x, geomCoords[1].y}, {util::EXTENT, 0})); - bucket->vertices.emplace_back(RasterProgram::layoutVertex({geomCoords[3].x, geomCoords[3].y}, {0, util::EXTENT})); + bucket->vertices.emplace_back(RasterBucket::layoutVertex({geomCoords[0].x, geomCoords[0].y}, {0, 0})); + bucket->vertices.emplace_back(RasterBucket::layoutVertex({geomCoords[1].x, geomCoords[1].y}, {util::EXTENT, 0})); + bucket->vertices.emplace_back(RasterBucket::layoutVertex({geomCoords[3].x, geomCoords[3].y}, {0, util::EXTENT})); bucket->vertices.emplace_back( - RasterProgram::layoutVertex({geomCoords[2].x, geomCoords[2].y}, {util::EXTENT, util::EXTENT})); + RasterBucket::layoutVertex({geomCoords[2].x, geomCoords[2].y}, {util::EXTENT, util::EXTENT})); bucket->indices.emplace_back(0, 1, 2); bucket->indices.emplace_back(1, 2, 3); diff --git a/src/mbgl/renderer/sources/render_image_source.hpp b/src/mbgl/renderer/sources/render_image_source.hpp index f0e2dc6ea..f54271103 100644 --- a/src/mbgl/renderer/sources/render_image_source.hpp +++ b/src/mbgl/renderer/sources/render_image_source.hpp @@ -21,7 +21,7 @@ public: private: void upload(gfx::UploadPass&) const override; - void render(PaintParameters&) const override; + void render(PaintParameters&) const override {} bool hasRenderPass(RenderPass) const override { return false; } const std::string& getName() const override { return name; } std::string name; diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp index 015f1fc05..37bbae8b0 100644 --- a/src/mbgl/renderer/sources/render_tile_source.cpp +++ b/src/mbgl/renderer/sources/render_tile_source.cpp @@ -43,12 +43,6 @@ void TileSourceRenderItem::upload(gfx::UploadPass& parameters) const { } } -void TileSourceRenderItem::render(PaintParameters& parameters) const { - for (auto& tile : *renderTiles) { - tile.finishRender(parameters); - } -} - #if MLN_ENABLE_POLYLINE_DRAWABLES class PolylineLayerImpl : public Layer::Impl { public: diff --git a/src/mbgl/renderer/sources/render_tile_source.hpp b/src/mbgl/renderer/sources/render_tile_source.hpp index 0256a5382..3b09f2758 100644 --- a/src/mbgl/renderer/sources/render_tile_source.hpp +++ b/src/mbgl/renderer/sources/render_tile_source.hpp @@ -99,7 +99,7 @@ public: private: void upload(gfx::UploadPass&) const override; - void render(PaintParameters&) const override; + void render(PaintParameters&) const override {} bool hasRenderPass(RenderPass) const override { return false; } const std::string& getName() const override { return name; } diff --git a/src/mbgl/style/layers/custom_drawable_layer.cpp b/src/mbgl/style/layers/custom_drawable_layer.cpp index 3df0ee2c4..04e49879c 100644 --- a/src/mbgl/style/layers/custom_drawable_layer.cpp +++ b/src/mbgl/style/layers/custom_drawable_layer.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -582,7 +581,7 @@ util::SimpleIdentity CustomDrawableLayerHost::Interface::addFill(const GeometryC const std::shared_ptr sharedTriangles = std::make_shared(); TriangleIndexVector& triangles = *sharedTriangles; - SegmentVector triangleSegments; + SegmentVector triangleSegments; // generate fill geometry into buffers gfx::generateFillBuffers(geometry, vertices, triangles, triangleSegments); @@ -642,8 +641,8 @@ util::SimpleIdentity CustomDrawableLayerHost::Interface::addSymbol( triangles.emplace_back(0, 1, 2, 1, 2, 3); - SegmentVector triangleSegments; - triangleSegments.emplace_back(Segment{0, 0, 4, 6}); + SegmentVector triangleSegments; + triangleSegments.emplace_back(0, 0, 4, 6); // add to builder auto attrs = context.createVertexAttributeArray(); @@ -697,8 +696,8 @@ util::SimpleIdentity CustomDrawableLayerHost::Interface::addGeometry( // geographic coordinates require tile {0, 0, 0} setTileID({0, 0, 0}); - SegmentVector triangleSegments; - triangleSegments.emplace_back(Segment{0, 0, vertices->elements(), indices->elements()}); + SegmentVector triangleSegments; + triangleSegments.emplace_back(0, 0, vertices->elements(), indices->elements()); // add to builder auto attrs = context.createVertexAttributeArray(); diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 88402e142..b8a222c51 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -1011,8 +1011,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, } if (symbolInstance.hasText()) { size_t textOpacityVerticesSize = 0u; - const auto& opacityVertex = SymbolSDFTextProgram::opacityVertex(opacityState.text.placed, - opacityState.text.opacity); + const auto& opacityVertex = SymbolBucket::opacityVertex(opacityState.text.placed, + opacityState.text.opacity); if (symbolInstance.getPlacedRightTextIndex()) { textOpacityVerticesSize += symbolInstance.getRightJustifiedGlyphQuadsSize() * 4; PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedRightTextIndex()]; @@ -1052,8 +1052,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, } if (symbolInstance.hasIcon()) { size_t iconOpacityVerticesSize = 0u; - const auto& opacityVertex = SymbolIconProgram::opacityVertex(opacityState.icon.placed, - opacityState.icon.opacity); + const auto& opacityVertex = SymbolBucket::opacityVertex(opacityState.icon.placed, + opacityState.icon.opacity); auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket.sdfIcon : bucket.icon; if (symbolInstance.getPlacedIconIndex()) { @@ -1073,7 +1073,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, if (feature.alongLine) { return; } - const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, false, shift); + const auto& dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, false, shift); bucket.iconCollisionBox->dynamicVertices().extend(feature.boxes.size() * 4, dynamicVertex); }; @@ -1109,7 +1109,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, used = false; } } - const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !used, shift); + const auto& dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, !used, shift); bucket.textCollisionBox->dynamicVertices().extend(feature.boxes.size() * 4, dynamicVertex); return shift; }; @@ -1121,14 +1121,14 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, auto circles = collisionCircles.find(&feature); if (circles != collisionCircles.end()) { for (const auto& circle : circles->second) { - const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !circle.isCircle(), {}); + const auto& dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, !circle.isCircle(), {}); isText ? bucket.textCollisionCircle->dynamicVertices().extend(4, dynamicVertex) : bucket.iconCollisionCircle->dynamicVertices().extend(4, dynamicVertex); } } else { // This feature was not placed, because it was not loaded or // from a fading tile. Apply default values. - static const auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, false /*not used*/, {}); + static const auto dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, false /*not used*/, {}); isText ? bucket.textCollisionCircle->dynamicVertices().extend(4 * feature.boxes.size(), dynamicVertex) : bucket.iconCollisionCircle->dynamicVertices().extend(4 * feature.boxes.size(), dynamicVertex); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a53e20d14..754dc9e2b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,7 +18,6 @@ add_library( ${PROJECT_SOURCE_DIR}/test/math/minmax.test.cpp ${PROJECT_SOURCE_DIR}/test/math/wrap.test.cpp ${PROJECT_SOURCE_DIR}/test/platform/settings.test.cpp - ${PROJECT_SOURCE_DIR}/test/programs/symbol_program.test.cpp ${PROJECT_SOURCE_DIR}/test/renderer/image_manager.test.cpp ${PROJECT_SOURCE_DIR}/test/renderer/pattern_atlas.test.cpp ${PROJECT_SOURCE_DIR}/test/renderer/shader_registry.test.cpp diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp index cf3d8e434..870a4d06c 100644 --- a/test/gl/bucket.test.cpp +++ b/test/gl/bucket.test.cpp @@ -18,8 +18,7 @@ namespace mbgl { -template -bool operator==(const Segment& lhs, const Segment& rhs) { +bool operator==(const SegmentBase& lhs, const SegmentBase& rhs) { return std::tie(lhs.vertexOffset, lhs.indexOffset, lhs.vertexLength, lhs.indexLength) == std::tie(rhs.vertexOffset, rhs.indexOffset, rhs.vertexLength, rhs.indexLength); } @@ -221,7 +220,7 @@ TEST(Buckets, RasterBucketMaskEmpty) { bucket.setMask({}); EXPECT_EQ((std::vector{}), bucket.vertices.vector()); EXPECT_EQ((std::vector{}), bucket.indices.vector()); - SegmentVector expectedSegments; + SegmentVector expectedSegments; expectedSegments.emplace_back(0, 0, 0, 0); EXPECT_EQ(expectedSegments, bucket.segments); } @@ -233,7 +232,7 @@ TEST(Buckets, RasterBucketMaskNoChildren) { // A mask of 0/0/0 doesn't produce buffers since we're instead using the global shared buffers. EXPECT_EQ((std::vector{}), bucket.vertices.vector()); EXPECT_EQ((std::vector{}), bucket.indices.vector()); - EXPECT_EQ((SegmentVector{}), bucket.segments); + EXPECT_EQ((SegmentVector{}), bucket.segments); } TEST(Buckets, RasterBucketMaskTwoChildren) { @@ -242,16 +241,16 @@ TEST(Buckets, RasterBucketMaskTwoChildren) { EXPECT_EQ((std::vector{ // 1/0/1 - RasterProgram::layoutVertex({0, 0}, {0, 0}), - RasterProgram::layoutVertex({4096, 0}, {4096, 0}), - RasterProgram::layoutVertex({0, 4096}, {0, 4096}), - RasterProgram::layoutVertex({4096, 4096}, {4096, 4096}), + RasterBucket::layoutVertex({0, 0}, {0, 0}), + RasterBucket::layoutVertex({4096, 0}, {4096, 0}), + RasterBucket::layoutVertex({0, 4096}, {0, 4096}), + RasterBucket::layoutVertex({4096, 4096}, {4096, 4096}), // 1/1/1 - RasterProgram::layoutVertex({4096, 4096}, {4096, 4096}), - RasterProgram::layoutVertex({8192, 4096}, {8192, 4096}), - RasterProgram::layoutVertex({4096, 8192}, {4096, 8192}), - RasterProgram::layoutVertex({8192, 8192}, {8192, 8192}), + RasterBucket::layoutVertex({4096, 4096}, {4096, 4096}), + RasterBucket::layoutVertex({8192, 4096}, {8192, 4096}), + RasterBucket::layoutVertex({4096, 8192}, {4096, 8192}), + RasterBucket::layoutVertex({8192, 8192}, {8192, 8192}), }), bucket.vertices.vector()); @@ -274,7 +273,7 @@ TEST(Buckets, RasterBucketMaskTwoChildren) { }), bucket.indices.vector()); - SegmentVector expectedSegments; + SegmentVector expectedSegments; expectedSegments.emplace_back(0, 0, 8, 12); EXPECT_EQ(expectedSegments, bucket.segments); } @@ -290,40 +289,40 @@ TEST(Buckets, RasterBucketMaskComplex) { EXPECT_EQ((std::vector{ // 1/0/1 - RasterProgram::layoutVertex({0, 4096}, {0, 4096}), - RasterProgram::layoutVertex({4096, 4096}, {4096, 4096}), - RasterProgram::layoutVertex({0, 8192}, {0, 8192}), - RasterProgram::layoutVertex({4096, 8192}, {4096, 8192}), + RasterBucket::layoutVertex({0, 4096}, {0, 4096}), + RasterBucket::layoutVertex({4096, 4096}, {4096, 4096}), + RasterBucket::layoutVertex({0, 8192}, {0, 8192}), + RasterBucket::layoutVertex({4096, 8192}, {4096, 8192}), // 1/1/0 - RasterProgram::layoutVertex({4096, 0}, {4096, 0}), - RasterProgram::layoutVertex({8192, 0}, {8192, 0}), - RasterProgram::layoutVertex({4096, 4096}, {4096, 4096}), - RasterProgram::layoutVertex({8192, 4096}, {8192, 4096}), + RasterBucket::layoutVertex({4096, 0}, {4096, 0}), + RasterBucket::layoutVertex({8192, 0}, {8192, 0}), + RasterBucket::layoutVertex({4096, 4096}, {4096, 4096}), + RasterBucket::layoutVertex({8192, 4096}, {8192, 4096}), // 2/2/3 - RasterProgram::layoutVertex({4096, 6144}, {4096, 6144}), - RasterProgram::layoutVertex({6144, 6144}, {6144, 6144}), - RasterProgram::layoutVertex({4096, 8192}, {4096, 8192}), - RasterProgram::layoutVertex({6144, 8192}, {6144, 8192}), + RasterBucket::layoutVertex({4096, 6144}, {4096, 6144}), + RasterBucket::layoutVertex({6144, 6144}, {6144, 6144}), + RasterBucket::layoutVertex({4096, 8192}, {4096, 8192}), + RasterBucket::layoutVertex({6144, 8192}, {6144, 8192}), // 2/3/2 - RasterProgram::layoutVertex({6144, 4096}, {6144, 4096}), - RasterProgram::layoutVertex({8192, 4096}, {8192, 4096}), - RasterProgram::layoutVertex({6144, 6144}, {6144, 6144}), - RasterProgram::layoutVertex({8192, 6144}, {8192, 6144}), + RasterBucket::layoutVertex({6144, 4096}, {6144, 4096}), + RasterBucket::layoutVertex({8192, 4096}, {8192, 4096}), + RasterBucket::layoutVertex({6144, 6144}, {6144, 6144}), + RasterBucket::layoutVertex({8192, 6144}, {8192, 6144}), // 3/6/7 - RasterProgram::layoutVertex({6144, 7168}, {6144, 7168}), - RasterProgram::layoutVertex({7168, 7168}, {7168, 7168}), - RasterProgram::layoutVertex({6144, 8192}, {6144, 8192}), - RasterProgram::layoutVertex({7168, 8192}, {7168, 8192}), + RasterBucket::layoutVertex({6144, 7168}, {6144, 7168}), + RasterBucket::layoutVertex({7168, 7168}, {7168, 7168}), + RasterBucket::layoutVertex({6144, 8192}, {6144, 8192}), + RasterBucket::layoutVertex({7168, 8192}, {7168, 8192}), // 3/7/6 - RasterProgram::layoutVertex({7168, 6144}, {7168, 6144}), - RasterProgram::layoutVertex({8192, 6144}, {8192, 6144}), - RasterProgram::layoutVertex({7168, 7168}, {7168, 7168}), - RasterProgram::layoutVertex({8192, 7168}, {8192, 7168}), + RasterBucket::layoutVertex({7168, 6144}, {7168, 6144}), + RasterBucket::layoutVertex({8192, 6144}, {8192, 6144}), + RasterBucket::layoutVertex({7168, 7168}, {7168, 7168}), + RasterBucket::layoutVertex({8192, 7168}, {8192, 7168}), }), bucket.vertices.vector()); @@ -378,7 +377,7 @@ TEST(Buckets, RasterBucketMaskComplex) { }), bucket.indices.vector()); - SegmentVector expectedSegments; + SegmentVector expectedSegments; expectedSegments.emplace_back(0, 0, 24, 36); EXPECT_EQ(expectedSegments, bucket.segments); } diff --git a/test/programs/symbol_program.test.cpp b/test/programs/symbol_program.test.cpp deleted file mode 100644 index ac33fc0b1..000000000 --- a/test/programs/symbol_program.test.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include - -#include -#include - -using namespace mbgl; -using namespace mbgl::style::expression::dsl; - -TEST(SymbolProgram, SymbolSizeBinder) { - auto binder = SymbolSizeBinder::create(5.0f, 12.0f, 0.0f); - auto uniformValues = binder->uniformValues(5.5f); - EXPECT_EQ(uniformValues.get(), true); - EXPECT_EQ(uniformValues.get(), true); - EXPECT_EQ(uniformValues.get(), 12.0f); - - binder = SymbolSizeBinder::create( - 1.0f, - style::PropertyExpression(interpolate(linear(), zoom(), 0., literal(8.), 10., literal(18.))), - 0.0f); - uniformValues = binder->uniformValues(1.5f); - EXPECT_EQ(uniformValues.get(), false); - EXPECT_EQ(uniformValues.get(), true); - EXPECT_EQ(uniformValues.get(), 9.5f); - - binder = SymbolSizeBinder::create( - 0.0f, - style::PropertyExpression(interpolate(linear(), zoom(), 1., literal(8.), 11., literal(18.))), - 0.0f); - uniformValues = binder->uniformValues(0.5f); - EXPECT_EQ(uniformValues.get(), false); - EXPECT_EQ(uniformValues.get(), true); - EXPECT_EQ(uniformValues.get(), 8.0f); - - binder = SymbolSizeBinder::create( - 12.0f, - style::PropertyExpression(interpolate(linear(), zoom(), 1., literal(8.), 11., literal(18.))), - 0.0f); - uniformValues = binder->uniformValues(12.5f); - EXPECT_EQ(uniformValues.get(), false); - EXPECT_EQ(uniformValues.get(), true); - EXPECT_EQ(uniformValues.get(), 18.0f); - - binder = SymbolSizeBinder::create( - 0.0f, - style::PropertyExpression(interpolate(linear(), number(get("x")), 1., literal(8.), 11., literal(18.))), - 0.0f); - uniformValues = binder->uniformValues(12.5f); - EXPECT_EQ(uniformValues.get(), true); - EXPECT_EQ(uniformValues.get(), false); - - binder = SymbolSizeBinder::create( - 5.0f, - style::PropertyExpression( - interpolate(linear(), - zoom(), - 1., - interpolate(linear(), number(get("x")), 0., literal(8.), 100., literal(18.)), - 11., - interpolate(linear(), number(get("x")), 0., literal(12.), 100., literal(24.9)))), - 0.0f); - uniformValues = binder->uniformValues(5.5f); - EXPECT_EQ(uniformValues.get(), false); - EXPECT_EQ(uniformValues.get(), false); - EXPECT_EQ(uniformValues.get(), 0.45f); -} diff --git a/test/renderer/shader_registry.test.cpp b/test/renderer/shader_registry.test.cpp index caabf8a6c..e8a308f69 100644 --- a/test/renderer/shader_registry.test.cpp +++ b/test/renderer/shader_registry.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include using namespace mbgl; @@ -214,7 +214,8 @@ TEST(ShaderRegistry, DISABLED_GLSLReplacement_NoOp) { // Just replace with a default instance observer.registerShaders = [&](gfx::ShaderRegistry& registry) { - if (!registry.getLegacyGroup().replaceShader(std::make_shared(ProgramParameters(1.0f, false)))) { + if (!registry.getLegacyGroup().replaceShader( + std::make_shared(ProgramParameters(1.0f, false)))) { throw std::runtime_error("Failed to register shader!"); } }; @@ -240,7 +241,7 @@ TEST(ShaderRegistry, DISABLED_GLSLReplacement1) { // Replace with an instance that only renders blue observer.registerShaders = [&](gfx::ShaderRegistry& registry) { - if (!registry.getLegacyGroup().replaceShader(std::make_shared( + if (!registry.getLegacyGroup().replaceShader(std::make_shared( ProgramParameters(1.0f, false) .withShaderSource(ProgramParameters::ProgramSource(gfx::Backend::Type::OpenGL, "", @@ -274,7 +275,7 @@ TEST(ShaderRegistry, DISABLED_GLSLReplacement2) { // Replace with an instance that adds some red and green observer.registerShaders = [&](gfx::ShaderRegistry& registry) { - if (!registry.getLegacyGroup().replaceShader(std::make_shared( + if (!registry.getLegacyGroup().replaceShader(std::make_shared( ProgramParameters(1.0f, false) .withShaderSource(ProgramParameters::ProgramSource(gfx::Backend::Type::OpenGL, "", diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp index 0c1a8286b..fae330a8a 100644 --- a/test/tile/vector_tile.test.cpp +++ b/test/tile/vector_tile.test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include