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

Antialias fills without gl.LINES #2080

Open
ansis opened this issue Feb 6, 2016 · 8 comments
Open

Antialias fills without gl.LINES #2080

ansis opened this issue Feb 6, 2016 · 8 comments
Labels

Comments

@ansis
Copy link
Contributor

ansis commented Feb 6, 2016

The minimum ALIASED_LINE_WIDTH_RANGE required by the spec is [1, 1]. We need at least a width of 2 for antialiasing to work. ANGLE only supports a width of 1. Angle is used in Chrome and Firefox on windows, and by our headless testing.

We should use triangles.

moving away from gl.LINES should fix #1047

It could also help without our headless testing antialiasing headaches.

@ansis
Copy link
Contributor Author

ansis commented Feb 6, 2016

cc @kkaefer

@lucaswoj
Copy link
Contributor

lucaswoj commented Feb 8, 2016

Do you think this is the same phenomena as #1606 (comment)?

@tmpsantos
Copy link
Contributor

ANGLE is also used on Mapbox GL Native + Qt on Windows.

@jfirebaugh
Copy link
Contributor

The core profile for desktop OpenGL on macOS supports only [1, 1] as well: https://developer.apple.com/opengl/OpenGL-Capabilities-Tables.pdf.

@jfirebaugh
Copy link
Contributor

Weirdly, support for >1 seems to have increased abrupt in recent months:

image

http://webglstats.com/webgl/parameter/ALIASED_LINE_WIDTH_RANGE

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Jul 17, 2017

@kkaefer pointed out a potential technique for doing polygon antialiasing/stroking using barycentric coordinates, and I spent some time prototyping it in gl-js. It's a clever technique, but unfortunately it doesn't look like it will work for us. The technique originates as a way of drawing wireframes, where all three sides of each triangle are stroked. When you want to stroke only some of the sides, the issue arises that the edges that are not stroked end up "cutting off" pieces of the stroke on adjacent edges:

image

The skinnier the triangles, the worse this gets -- and earcut tends to generate a lot of very skinny triangles.

You could try to correct for this by shading portions of the other triangles that cover that border, but this doesn't seem straightforward, and I couldn't find any papers or threads online that discussed it.

A second issue with this technique is that it will only allow us to antialias or stroke the interior of the polygon. An interior-only antialiasing would likely produce or exacerbate seams between polygons that share an edge. What we really want is a 50/50 split between the interior and exterior, and to get that, we'd need to implement polygon outset, a complex algorithm.

@exotfboy
Copy link

Hi , I found that the Antialias also does not work with the fill-extrusion.

image

@alphex
Copy link

alphex commented Oct 25, 2022

I'm suffering from this issue also.
I found that setting a 1px stroke with 50% opacity of the same color solved the issue... but .. yeah, doesn't work as advertised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants