maplibre / maplibre-gl-js

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

Support Fog in Mercator projection without Terrain3D #4337

Open birkskyum opened 5 months ago

birkskyum commented 5 months ago

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

Repro is to disable the terrain here https://maplibre.org/maplibre-gl-js/docs/examples/sky-with-fog-and-terrain/

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 5 months 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...

Uranbold commented 2 months ago

I've tested it, and we cannot activate Vector tiles. FOG is not active on Vector. How can we achieve this?