Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MapLibre GL JS to 49bc4ca45 #328

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion maplibre-gl-js
Submodule maplibre-gl-js updated 487 files
23 changes: 17 additions & 6 deletions platform/ios/platform/darwin/src/MGLSymbolStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,21 @@ typedef NS_ENUM(NSUInteger, MGLSymbolPlacement) {
};

/**
Controls the order in which overlapping symbols in the same layer are rendered
Determines whether overlapping symbols in the same layer are rendered in the
wipfli marked this conversation as resolved.
Show resolved Hide resolved
order that they appear in the data source or by their y-position relative to
the viewport. To control the order and prioritization of symbols otherwise, use
`MGLSymbolStyleLayer.symbolSortKey`.

Values of this type are used in the `MGLSymbolStyleLayer.symbolZOrder`
property.
*/
typedef NS_ENUM(NSUInteger, MGLSymbolZOrder) {
/**
If `MGLSymbolStyleLayer.symbolSortKey` is set, sort based on that.
Otherwise sort symbols by their y-position relative to the viewport.
Sorts symbols by `MGLSymbolStyleLayer.symbolSortKey` if set. Otherwise,
sorts symbols by their y-position relative to the viewport if
`iconAllowOverlap` or `textAllowOverlap` is set to `YES` or
`MGLTextAllowOverlapIconIgnorePlacement` or `textIgnorePlacement` is
`false`.
*/
MGLSymbolZOrderAuto,
/**
Expand Down Expand Up @@ -1100,7 +1106,10 @@ MGL_EXPORT
@property (nonatomic, null_resettable) NSExpression *symbolSpacing;

/**
Controls the order in which overlapping symbols in the same layer are rendered
Determines whether overlapping symbols in the same layer are rendered in the
order that they appear in the data source or by their y-position relative to
the viewport. To control the order and prioritization of symbols otherwise, use
`symbolSortKey`.

The default value of this property is an expression that evaluates to `auto`.
Set this property to `nil` to reset it to the default value.
Expand All @@ -1109,8 +1118,10 @@ MGL_EXPORT

* Constant `MGLSymbolZOrder` values
* Any of the following constant string values:
* `auto`: If `symbol-sort-key` is set, sort based on that. Otherwise sort
symbols by their y-position relative to the viewport.
* `auto`: Sorts symbols by `symbol-sort-key` if set. Otherwise, sorts symbols
by their y-position relative to the viewport if `icon-allow-overlap` or
`text-allow-overlap` is set to `true` or `icon-ignore-placement` or
`text-ignore-placement` is `false`.
* `viewport-y`: Specify this z order if symbols’ appearance relies on lower
features overlapping higher features. For example, symbols with a pin-like
appearance would require this z order.
Expand Down
102 changes: 54 additions & 48 deletions src/mbgl/programs/gl/collision_circle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<CollisionCircleProgram> {
static constexpr const char* name = "collision_circle";
static constexpr const uint8_t hash[8] = {0x99, 0x2e, 0xad, 0x8c, 0xd3, 0x88, 0xae, 0x82};
static constexpr const uint8_t hash[8] = {0x8c, 0x22, 0x17, 0x46, 0x5b, 0xed, 0x28, 0x64};
static constexpr const auto vertexOffset = 10902;
static constexpr const auto fragmentOffset = 11818;
static constexpr const auto fragmentOffset = 12272;
};

constexpr const char* ShaderSource<CollisionCircleProgram>::name;
Expand All @@ -40,79 +40,85 @@ Backend::Create<gfx::Backend::Type::OpenGL>(const ProgramParameters& programPara
// Uncompressed source of collision_circle.vertex.glsl:
/*
attribute vec2 a_pos;
attribute vec2 a_anchor_pos;
attribute vec2 a_extrude;
attribute vec2 a_placed;
attribute float a_radius;
attribute vec2 a_flags;

uniform mat4 u_matrix;
uniform vec2 u_extrude_scale;
uniform mat4 u_inv_matrix;
uniform vec2 u_viewport_size;
uniform float u_camera_to_center_distance;

varying float v_placed;
varying float v_notUsed;
varying float v_radius;

varying vec2 v_extrude;
varying vec2 v_extrude_scale;
varying float v_perspective_ratio;
varying float v_collision;

vec3 toTilePosition(vec2 screenPos) {
// Shoot a ray towards the ground to reconstruct the depth-value
vec4 rayStart = u_inv_matrix * vec4(screenPos, -1.0, 1.0);
vec4 rayEnd = u_inv_matrix * vec4(screenPos, 1.0, 1.0);

rayStart.xyz /= rayStart.w;
rayEnd.xyz /= rayEnd.w;

highp float t = (0.0 - rayStart.z) / (rayEnd.z - rayStart.z);
return mix(rayStart.xyz, rayEnd.xyz, t);
}

void main() {
vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);
highp float camera_to_anchor_distance = projectedPoint.w;
vec2 quadCenterPos = a_pos;
float radius = a_radius;
float collision = a_flags.x;
float vertexIdx = a_flags.y;

vec2 quadVertexOffset = vec2(
mix(-1.0, 1.0, float(vertexIdx >= 2.0)),
mix(-1.0, 1.0, float(vertexIdx >= 1.0 && vertexIdx <= 2.0)));

vec2 quadVertexExtent = quadVertexOffset * radius;

// Screen position of the quad might have been computed with different camera parameters.
// Transform the point to a proper position on the current viewport
vec3 tilePos = toTilePosition(quadCenterPos);
vec4 clipPos = u_matrix * vec4(tilePos, 1.0);

highp float camera_to_anchor_distance = clipPos.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;
// Apply small padding for the anti-aliasing effect to fit the quad
// Note that v_radius and v_extrude are in screen coordinates already
float padding_factor = 1.2;
v_radius = radius;
v_extrude = quadVertexExtent * padding_factor;
v_perspective_ratio = collision_perspective_ratio;
v_collision = collision;

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;
gl_Position = vec4(clipPos.xyz / clipPos.w, 1.0) + vec4(quadVertexExtent * padding_factor / u_viewport_size * 2.0, 0.0, 0.0);
}

*/

// Uncompressed source of collision_circle.fragment.glsl:
/*
uniform float u_overscale_factor;

varying float v_placed;
varying float v_notUsed;
varying float v_radius;
varying vec2 v_extrude;
varying vec2 v_extrude_scale;
varying float v_perspective_ratio;
varying float v_collision;

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 alpha = 0.5 * min(v_perspective_ratio, 1.0);
float stroke_radius = 0.9 * max(v_perspective_ratio, 1.0);

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_center = length(v_extrude);
float distance_to_edge = abs(distance_to_center - v_radius);
float opacity_t = smoothstep(-stroke_radius, 0.0, -distance_to_edge);

float distance_to_edge = abs(extrude_length - radius);
float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);
vec4 color = mix(vec4(0.0, 0.0, 1.0, 0.5), vec4(1.0, 0.0, 0.0, 1.0), v_collision);

gl_FragColor = opacity_t * color;
gl_FragColor = color * alpha * opacity_t;
}

*/
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/programs/gl/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template <>
struct ShaderSource<DebugProgram> {
static constexpr const char* name = "debug";
static constexpr const uint8_t hash[8] = {0x07, 0x98, 0x41, 0xa8, 0x6b, 0x73, 0xaf, 0x34};
static constexpr const auto vertexOffset = 12494;
static constexpr const auto fragmentOffset = 12672;
static constexpr const auto vertexOffset = 12763;
static constexpr const auto fragmentOffset = 12941;
};

constexpr const char* ShaderSource<DebugProgram>::name;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/programs/gl/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template <>
struct ShaderSource<FillProgram> {
static constexpr const char* name = "fill";
static constexpr const uint8_t hash[8] = {0x87, 0xea, 0x65, 0x7f, 0x0c, 0x9b, 0x97, 0x5d};
static constexpr const auto vertexOffset = 12862;
static constexpr const auto fragmentOffset = 13506;
static constexpr const auto vertexOffset = 13131;
static constexpr const auto fragmentOffset = 13775;
};

constexpr const char* ShaderSource<FillProgram>::name;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/programs/gl/fill_extrusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template <>
struct ShaderSource<FillExtrusionProgram> {
static constexpr const char* name = "fill_extrusion";
static constexpr const uint8_t hash[8] = {0x9d, 0x76, 0x7f, 0xaa, 0x86, 0x57, 0x56, 0x96};
static constexpr const auto vertexOffset = 21491;
static constexpr const auto fragmentOffset = 23422;
static constexpr const auto vertexOffset = 22902;
static constexpr const auto fragmentOffset = 24833;
};

constexpr const char* ShaderSource<FillExtrusionProgram>::name;
Expand Down
75 changes: 65 additions & 10 deletions src/mbgl/programs/gl/fill_extrusion_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<FillExtrusionPatternProgram> {
static constexpr const char* name = "fill_extrusion_pattern";
static constexpr const uint8_t hash[8] = {0x5a, 0x8f, 0x1a, 0xbf, 0x43, 0x62, 0xf0, 0x86};
static constexpr const auto vertexOffset = 23538;
static constexpr const auto fragmentOffset = 26509;
static constexpr const uint8_t hash[8] = {0x66, 0xa3, 0xd9, 0x87, 0x9b, 0x01, 0x0c, 0xeb};
static constexpr const auto vertexOffset = 24949;
static constexpr const auto fragmentOffset = 28539;
};

constexpr const char* ShaderSource<FillExtrusionPatternProgram>::name;
Expand All @@ -43,7 +43,7 @@ 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 vec3 u_scale;
uniform float u_vertical_gradient;
uniform lowp float u_opacity;

Expand Down Expand Up @@ -95,6 +95,24 @@ uniform lowp vec4 u_pattern_to;
#endif


#ifndef HAS_UNIFORM_u_pixel_ratio_from
uniform lowp float u_pixel_ratio_from_t;
attribute lowp vec2 a_pixel_ratio_from;
varying lowp float pixel_ratio_from;
#else
uniform lowp float u_pixel_ratio_from;
#endif


#ifndef HAS_UNIFORM_u_pixel_ratio_to
uniform lowp float u_pixel_ratio_to_t;
attribute lowp vec2 a_pixel_ratio_to;
varying lowp float pixel_ratio_to;
#else
uniform lowp float u_pixel_ratio_to;
#endif


void main() {

#ifndef HAS_UNIFORM_u_base
Expand Down Expand Up @@ -124,22 +142,35 @@ void main() {
mediump vec4 pattern_to = u_pattern_to;
#endif


#ifndef HAS_UNIFORM_u_pixel_ratio_from
pixel_ratio_from = unpack_mix_vec2(a_pixel_ratio_from, u_pixel_ratio_from_t);
#else
lowp float pixel_ratio_from = u_pixel_ratio_from;
#endif


#ifndef HAS_UNIFORM_u_pixel_ratio_to
pixel_ratio_to = unpack_mix_vec2(a_pixel_ratio_to, u_pixel_ratio_to_t);
#else
lowp float pixel_ratio_to = u_pixel_ratio_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_scale.x;
float tileRatio = u_scale.y;
float fromScale = u_scale.z;
float toScale = u_scale.w;
float tileRatio = u_scale.x;
float fromScale = u_scale.y;
float toScale = u_scale.z;

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);
vec2 display_size_a = (pattern_br_a - pattern_tl_a) / pixel_ratio_from;
vec2 display_size_b = (pattern_br_b - pattern_tl_b) / pixel_ratio_to;

base = max(0.0, base);
height = max(0.0, height);
Expand Down Expand Up @@ -214,6 +245,20 @@ uniform lowp vec4 u_pattern_to;
#endif


#ifndef HAS_UNIFORM_u_pixel_ratio_from
varying lowp float pixel_ratio_from;
#else
uniform lowp float u_pixel_ratio_from;
#endif


#ifndef HAS_UNIFORM_u_pixel_ratio_to
varying lowp float pixel_ratio_to;
#else
uniform lowp float u_pixel_ratio_to;
#endif


void main() {

#ifdef HAS_UNIFORM_u_base
Expand All @@ -235,6 +280,16 @@ void main() {
mediump vec4 pattern_to = u_pattern_to;
#endif


#ifdef HAS_UNIFORM_u_pixel_ratio_from
lowp float pixel_ratio_from = u_pixel_ratio_from;
#endif


#ifdef HAS_UNIFORM_u_pixel_ratio_to
lowp float pixel_ratio_to = u_pixel_ratio_to;
#endif


vec2 pattern_tl_a = pattern_from.xy;
vec2 pattern_br_a = pattern_from.zw;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/programs/gl/fill_outline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template <>
struct ShaderSource<FillOutlineProgram> {
static constexpr const char* name = "fill_outline";
static constexpr const uint8_t hash[8] = {0x51, 0x25, 0x43, 0x9d, 0x41, 0x73, 0xe1, 0xbb};
static constexpr const auto vertexOffset = 13930;
static constexpr const auto fragmentOffset = 14755;
static constexpr const auto vertexOffset = 14199;
static constexpr const auto fragmentOffset = 15024;
};

constexpr const char* ShaderSource<FillOutlineProgram>::name;
Expand Down
Loading