Skip to content

antialiasing for custom layers #7543

Closed

Description

@ansis

mapbox-gl-js version: 0.51 / master

browser: all

Steps to Trigger Behavior

  1. create a custom layer that uses a renderer that assumes the webgl context provides antialiasing. For example /debug/threejs.html

Link to Demonstration

yarn start-debug
http://localhost:9966/debug/threejs.html

Expected Behavior

Antialiased rendering.

Actual Behavior

screen shot 2018-11-02 at 8 09 38 am


mapbox-gl doesn't use browser provided antialiasing. Instead we antialias layers ourselves by blurring edges, etc. We haven't revisited this decision recently. I think the original reasons for not using browser provided antialiasing were maybe:

  • it isn't supported everywhere (it depends on drivers, etc)
  • performance. We thought it might be cheaper to do it ourselves (I'm not sure if we've ever measured it though!)

Since we are not requesting antialiased contexts custom layers don't have access to browser-provided antialiasing.

Even if we were creating contexts with antialiasing, we currently render custom layers into framebuffers which don't ever have it. We should switch to rendering directly into the main framebuffer anyways. It should be faster.

Possible solutions:

A) expose antialias Map option

Expose an antialias option for Map that creates contexts with antialiasing when possible. This is the easiest change but it also don't fix the problem by default and it doesn't fix antialiasing for building layers.

B) request antialias by default

We should measure the performance costs of this so that we aren't making our maps slower if we don't need to. We would also need to check if this regresses our rendering (I think it should be ok).

C) request antialias when we have buildings or custom layers

The problem here is that we can't know if a building or custom layer will be added in the future. We could decide based on the initial style. Or we could request a new one if one of these layers is added, but that could be hard to do seamlessly.

D) provide other antialiasing for custom layers

We could provide FXAA (or something like it) for custom layers but I think this isn't what people expect and it could be more expensive.

Activity

  1. added a commit that references this issue on Jan 25, 2019
    6cba5b9
  2. added a commit that references this issue on Feb 25, 2019
    6ee5daf
  3. added a commit that references this issue on Feb 25, 2019
    ed3d0e1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions