Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

antialiasing on polygons - not transitioning to mapbox-gl-native #9690

Closed
miles-dev opened this issue Aug 2, 2017 · 2 comments
Closed

antialiasing on polygons - not transitioning to mapbox-gl-native #9690

miles-dev opened this issue Aug 2, 2017 · 2 comments
Labels
Core The cross-platform C++ core, aka mbgl rendering

Comments

@miles-dev
Copy link

Platform: Web (via above API) and mobile
Mapbox SDK version: Latest

Expected behavior

The same lines you see in web via Studio would persist to the mobile and raster-tiles-from-styles API maps.

Actual behavior

These antialias lines on the polygons are dropped when transitioning from mapbox-gl-js to mapbox-gl-native.


More details/screenshots:

When using https://www.mapbox.com/api-documentation/#retrieve-raster-tiles-from-styles, we noticed that anti-aliasing on polygons appears to not perform equivalent to mapbox-gl-js.

This can be seen in the below screenshots:

  • Style as viewed in Studio (note the lines):
    image
  • Resulting tile from the above API (lines are missing):
    image
  • Same style shown on mobile (lines are still missing):
    image
  • GIF of enabling/disabling antialias in Studio to see how it matches the above screenshots:
    antialias
@kkaefer kkaefer added Core The cross-platform C++ core, aka mbgl rendering labels Aug 3, 2017
@kkaefer
Copy link
Member

kkaefer commented Aug 3, 2017

It looks like this issue occurs when rendering fill layers that use DDS values for fill color. In this case, there is no antialiasing between polygons on the same layer. When we built the initial fill layer rendering, the assumption was that we don't want antialiasing between polygons in the same layer that line up to avoid artifacts.

We're rendering polygon outlines in the same color as the polygon in order to achieve an antialiasing effect. In this case, the rendering order works like this:

  • (opaque pass) draw fill, write to depth buffer
  • (translucent pass) draw outline, obeying depth buffer that cuts out half of the outline, so that we only render one "side" of the line

When the outline color didn't match the fill color, we did it this way:

  • (opaque pass) draw fill, write to depth buffer
  • (translucent pass) draw outline, not obeying depth buffer for this particular layer, but obeying it for other layers

This seems to be the part that broke:

  • We no longer ignore the depth buffer when rendering because the sublayer for a colored outline now has value 2 (instead of 0, as it used to be)
  • We're writing fragments we draw for outlines to the depth buffer, but should not do this, since the outline shader produces translucent fragments
  • We're drawing the outline before drawing the fill when the fill color is translucent

@kkaefer
Copy link
Member

kkaefer commented Aug 3, 2017

Rendering in Native with the fix applied:

mapbox gl 2017-08-03 12-35-28

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl rendering
Projects
None yet
Development

No branches or pull requests

2 participants