maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.29k stars 685 forks source link

Some vector layers on more distant tiles are not rendered for pitched 3D terrain map #1618

Open zdila opened 2 years ago

zdila commented 2 years ago

maplibre-gl-js version: 2.4.0

browser: Vivaldi, Firefox

Steps to Trigger Behavior

  1. create a map with vector style and 3D terrain
  2. zoom it, pitch it

Link to Demonstration

https://labs.maptiler.com/showcase/osm-3d-terrain/#map=13.05/48.8144/21.5301/59.28/75.50&language=sk

Expected Behavior

All visible layers should be rendered.

Actual Behavior

Some vector layers (eg. some landcover type) on more distant tiles are not rendered for pitched 3D terrain map.

image

HarelM commented 2 years ago

This is by design. To improve performance and make sure we are not loading too many tiles, the distant tiles are using a lower zoom level tiles. In your case, since the pitch is over 60 degrees and the horizon is visible, if this algorithm was not implemented the entire world tiles would have needed to be downloaded and rendered. Not a great solution :-) I guess you'll be able to see more details when you pan the map further into the distance, right?

zdila commented 2 years ago

@HarelM that is not the case. You can see gray residential areas and streets but not forests. If you disable 3D (or set pitch to zero) and will zoom out, you will see that residential areas and residential and other minor roads disappear before forests. There is no zoom with tiles containing those roads without forests in that style.

HarelM commented 2 years ago

I see. Thanks for the info! Can you try and create a simplified style that shows this issue maybe?

zdila commented 2 years ago

I will do it.

zdila commented 2 years ago

Here is the minimal-style demo: https://codesandbox.io/s/maplibre-gl-js-issue-1618-8wzxue

Too see something you must zoom in, for example: https://8wzxue.csb.app/#map=14.28/48.85968/19.36918/-101.31/69.90

There are two layers - one shows landcover to zoom 13 and other shows landcover from zoom 13. If there is only one landcover layer used for all zooms, then the issue is not reproducible.

HarelM commented 2 years ago

I only see one layer in the above link... am I missing something? Not that the issue does not exists there, but just want to make sure I'm looking at the right example...

image
zdila commented 2 years ago

In style.json there are two layers. I am actually not counting the third one - shading.

prozessor13 commented 2 years ago

Hi, this is related to LOD (level of detail). You defined a minZoom of 13, tiles near the horizon are requested for 12.

zdila commented 2 years ago

There are two layers - one has "minzoom": 13 other has "maxzoom": 13. Affected tiles have nothing there from neither of the layers.

HarelM commented 2 years ago

@zdila sorry for nagging, but can you simplify this even further - remove the style.json file, remove the hill shading and just have everything in the same file so it will be easy to see and understand?

zdila commented 2 years ago

@HarelM no problem. I've updated the testcase. Let me know if I could do anything more.

prozessor13 commented 2 years ago

Ah ok, didnt noticed (only noticed the minzoom)! Yes this is an issue. How to fix. hmmm. I can think something where it comes from, but may it is not easy to fix... is this issue also in 2d? If you are interested in fixing this ;), i may can give you some hints to start with.

prozessor13 commented 2 years ago

Tested by myself, and as expected, this issue is also in 2D. So this is no Terrain-3D issue. It is an LOD issue when tilting map more that 60deg.

HarelM commented 2 years ago

I don't see the problem when terrain is "off", @prozessor13 can you share what you saw? Terrain commented out: image Terrain not commented out: image

zdila commented 2 years ago

is this issue also in 2d

"Partially" :-)

If 3D terrain is not enabled, then I see also more distant tiles, but not "to the infinity". I would expect to see the horizont in the red colour (as for zoom < 13 the styling is red).

Samples:

  1. 3D enabled:

image

  1. 3D disabled:

image

  1. 3D disabled and slightly zoomed out:

image

  1. 3D enabled and slightly zoomed out:

image

prozessor13 commented 2 years ago

Yep. in 2D tile-list generation anchor is map-center, in 3d camera-position. So in 2d you get more tiles to the horizon, but the error is the same.

HarelM commented 1 year ago

I'm not sure how to categorize this in terms of label - is this a bug or a enhancement? Is it only in 3D?