Skip to content

Commit

Permalink
Fix line placement symbol disappearing issue when in zoom level 5 (in…
Browse files Browse the repository at this point in the history
…ternal-2172)

* WIP

* WIP

* Use ifdef as PROJECTED_POS_ON_VIEWPORT may not be defined

* remove unused shader code

* Add a new render test

* Update image

* revert debug page change

* Update expectation

---------

Co-authored-by: zmiao <[email protected]>
  • Loading branch information
2 people authored and underoot committed Feb 13, 2025
1 parent 340023d commit 057c34b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/shaders/symbol.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ void main() {

vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 proj_pos = mix_globe_mercator(a_projected_pos.xyz + h, mercator_pos, u_zoom_transition);
projected_pos = u_label_plane_matrix * vec4(proj_pos, 1.0);
#ifdef PROJECTED_POS_ON_VIEWPORT
projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xyz + h, 1.0);
#else
vec3 proj_pos = mix_globe_mercator(a_projected_pos.xyz, mercator_pos, u_zoom_transition) + h;
projected_pos = u_label_plane_matrix * vec4(proj_pos, 1.0);
#endif
#else
projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, h.z, 1.0);
#endif
Expand All @@ -214,15 +218,9 @@ void main() {
// Symbols might end up being behind the camera. Move them AWAY.
float occlusion_fade = globe_occlusion_fade;

float projection_transition_fade = 1.0;
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade = 1.0 - step(EPSILON, u_zoom_transition);
#endif
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(occlusion_fade, fade_opacity[0] + fade_change));

float out_fade_opacity = interpolated_fade_opacity * projection_transition_fade;
float out_fade_opacity = max(0.0, min(occlusion_fade, fade_opacity[0] + fade_change));

#ifdef DEPTH_OCCLUSION
float depth_occlusion = occlusionFadeMultiSample(projected_point);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"version": 8,
"metadata": {
"test": {
"height": 300,
"width": 200,
"operations": [
["setProjection", "globe"],
["wait"],
["setZoom", 3.2],
["wait"],
["setZoom", 5.5],
["wait"]
]
}
},
"center": [
-73.9987,
42.0
],
"zoom": 0,
"pitch": 0,
"bearing": 0,
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "LineString",
"coordinates": [
[
-74.00438542864366,
40.71275107696869
],
[
-72.658680,
46.243919
]
]
}
}
},
"sprite": "local://sprites/emerald",
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-color": "gray"
}
},
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-image": "interstate_3",
"icon-allow-overlap": true,
"symbol-placement": "line",
"symbol-spacing": 12.0,
"icon-size": 0.6
}
}
]
}

0 comments on commit 057c34b

Please sign in to comment.