maplibre / maplibre-gl-js

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

Sharper symbols with multichannel signed distance fields #3705

Open wipfli opened 5 months ago

wipfli commented 5 months ago

I would like to try out multichannel signed distance fields (MSDF) because the should give us sharper corners for text letters and icons than the currently used signed distance fields. This issue is here to keep track of the current status and collect some material.

Overview

The basic advantage of MSDFs is that you get sharper corners. Here is an example from https://github.com/Chlumsky/msdfgen

image

From left to right: 16x16 MSDF, 16x16 SDF, 32x32 SDF.

In an MSDF you store 3 different signed distance fields in the 3 color channels of an RGB image. So this means you need 3x more data. However, the 16x16 MSDF still outperforms the 32x32 SDF in terms of corner quality.

To learn more about MSDFs I recommend reading this Master thesis

Goal

My goal is to have a proof-of-concept version of MapLibre GL JS which just shows a single MSDF letter on a map. Once we have this we can extend it.

HarelM commented 5 months ago

It's worth mentioning that the following issue talks about multi sdf a bit:

wipfli commented 4 months ago

The demo here image can now show a single letter via the icon-image channel.

https://wipfli.github.io/maplibre-msdf-demo/#map=3/47/8

wipfli commented 4 months ago

Great new blog post on msdf https://www.redblobgames.com/x/2404-distance-field-effects/

wipfli commented 4 months ago

Large and sharp text in the Meta map style:

https://wipfli.github.io/maplibre-msdf-demo/meta#map=11.84/51.50079/-0.12431

Screenshot_20240304-220042

HarelM commented 4 months ago

Nice!!