Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SDF sprites #947

Merged
merged 1 commit into from
Jul 17, 2023
Merged

Conversation

petrsloup
Copy link
Member

This PR adds support for SDF sprites.

Though not very well documented, the mapbox-gl-js has support SDF sprites for years.
Such sprites contain "distances" instead of the regular color information:
image
In such cases, the sprite.json has a sdf: true on each image.

The benefits of the SDF sprites include better scalability and ability to recolor the images nicely.
We would like to start using SDF sprites in MapTiler in the future, but still remain compatible with the ol+ol-mapbox-style stack, so this PR adds a basic support for the SDF sprites.

  • In case of regular icons, the whole sprite image atlas is "unSDFied" once when it's first needed and then used the regular way (color tinting works the same as before)
  • In case of halo, only the specific icon is "unSDFied" with proper coloring and halo color. (Color tinting would also tint the halo, so the color needs to be burned in.)
  • SDF sprites are not supported in patterns, the is the case even in the mapbox specification.

There is no performance change for non-SDF sprites at all.

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @petrsloup!

@ahocevar ahocevar merged commit 0069afd into openlayers:main Jul 17, 2023
1 check passed
@petrsloup petrsloup deleted the sdf-sprites branch July 17, 2023 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants