maplibre / maplibre-gl-js

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

Render more layers to texture #1607

Open prozessor13 opened 2 years ago

prozessor13 commented 2 years ago

Based on the discussion on: https://github.com/maplibre/maplibre-gl-js/issues/1368#issuecomment-1236198156

It is important to try to render more layers in once to a texture. Currently only background, fill, linstring, raster are rendered onto texture. This should be expand to symbols and hillshading in special circumstances:

Both layers can contain expressions in layout properties, so this has to keep in mind when decide to render to texture or not!

Generall question to hillshade layer:

currently hillshade is re-rendered every animation-frame, because of the default illumination-anchor setted to viewport. But makes this sense? Especially in terrain-3d, in a minimal stylesheet with a hillshade layer, at least 3 textures are needed (why see: https://github.com/maplibre/maplibre-gl-js/issues/1368). With the anchor setted to map only on texture would needed -> a big win in performance!

So my proposal is: let's change the default anchor to map. What is the benefit of currently viewport? Is this expected when rotating the map? In real-world not, light depends on the day-time.

By the way: Mapbox renders hillshade layer onto texture by default, even in viewport mode, what results in mixed shadows between tiles when rotation the map.

HarelM commented 2 years ago

I think this is a great discussion to have! Regarding hillshade in 2D - this is the best way to feel 3D without the 3D - the fact that the light changes always make you know intuitively what is a mountain and what is a valley. The human brain is wired that way, I'll let you decide intuitively which of the two is a mountain and which is a valley (same item, different lighting) :-) image So for "regular" 2D this is very important and easy to use and understand. My two cents of how I envision 3D which might not be relevant to everyone is the following: I basically want to have 3D always on, but when looking from straight upwards I want the map to behave as best as it can being 2D including hillshading light and everything, but when pitching the map I want the 3D to be visible. This is how I envision the UX - the user shouldn't toggle any button to move from 2D to 3D. the user should simply change the pitch and have the 3D there. It might require effort from my side as a developer around maplibre and it might not be a part of maplibre but I think it should be taken into consideration in this discussion. :-) If the tone above is anything but technical I apologize - I think you are doing a great job regarding 3D and I just want to add my small perspective.

prozessor13 commented 2 years ago

I totally agree with you. I already made such a map-control for our company. The 3D button is still there, but do nothing more than tilt the map (with 3d automatically on). When pitch comes back to zero also exaggeration gets to zero. With pitch=0 3D is automatically diabled (because 2d has a better performance).

Thanks to your explanation, now i understand the viewport logic in 2d, but how to deal in 3d with hillshading? especially during tilt-animation?

zstadler commented 2 years ago

Here are my thoughts on some of the topic that were brought here: