mapbox-gl-js
mapbox-gl-js copied to clipboard
Some symbols disappear in globe projection between zoom levels 5 and 6
mapbox-gl-js version: 2.13.0
browser: Chrome 111
Description
Symbols of these types:
- Line labels
- Point labels with variable anchors
- Symbols with both
text-variable-anchor
andicon-text-fit
set
are not rendered in globe projection between GLOBE_ZOOM_THRESHOLD_MIN
and GLOBE_ZOOM_THRESHOLD_MAX
.
Steps to Trigger Behavior
- Go to https://codepen.io/osvodef/pen/povExxg
- Zoom in
Link to Demonstration
https://codepen.io/osvodef/pen/povExxg
Expected Behavior
All labels stay visible while crossing zoom levels 5–6
Actual Behavior
3 labels disappear, 1 stays
Additional info
I did a bit of detective work myself on this issue, hope this helps.
I tracked the bug down to symbol vertex shaders and u_zoom_transition
uniform. Forcing its value to 0 makes the labels appear, but on wrong positions on the screen, as if no globe→mercator transition is happening.
In the shaders, I found this line that hides the labels when u_zoom_transition > 0
:
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade = 1.0 - step(EPSILON, u_zoom_transition);
#endif
However, just removing this line doesn’t fix the issue since the screen coordinates calculated by the shader are also wrong when u_zoom_transition > 0
, usually putting the symbol completely off-screen.
The projection_transition_fade
line suggests that this was done intentionally, however, I couldn’t find any relevant discussion in PRs/issues here so I decided to report it anyway.