maplibre / maplibre-gl-js

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

Fog in 2D #4337

Open birkskyum opened 4 days ago

birkskyum commented 4 days ago

Current, the fog is part of the hillshade/terrain shader, and thus only active on Terrain 3D mode.

If would be great also to have the fog in 2D.

Below, I've taken the terrain3d shader and just passed it a 0 elevation, which will give a flat terrain with fog (and hillshade). I don't know if it's the best path to go to "always/default" run through the terrain shader.

The advantage is that we don't need conditional logic around 3d or not 3d, so positioning objects and tile handling might become easier / more consistent, also with globe mode. Disadvantage might be unwanted overhead in cases where none of it is needed, but maybe it's better to just opt-out there.

before

Screenshot 2024-06-27 at 16 03 55

after

Screenshot 2024-06-27 at 16 03 31
HarelM commented 4 days ago

Taking the texture is problematic in terms of performance and how the hillshade behaves when rotating the map - these are the problematic parts of the terrain implementation. But maybe this approach can be used as a separate shader somehow differently, IDK...