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

Render Antialiasing to Stencil Buffer #62

Closed
kkaefer opened this issue Sep 9, 2013 · 4 comments
Closed

Render Antialiasing to Stencil Buffer #62

kkaefer opened this issue Sep 9, 2013 · 4 comments

Comments

@kkaefer
Copy link
Member

kkaefer commented Sep 9, 2013

When rendering the antialiasing outlines for polygon, we should render them to the 8-bit stencil buffer and then somehow use that mask to affect opacity. This allows us to do alpha-blending of the entire polygon without having a special outline that has different shading/color than the rest of the polgyon area.

@ansis
Copy link
Contributor

ansis commented Sep 16, 2013

If I'm understanding things correctly, the only way to change the value of the stencil buffer is to set stencilOp to invert, increment, decrement, or set a constant (per draw call value). I'm not seeing a way to write (or then use) arbitrary fragment-shader-determined values.

I can't see how using the stencil buffer to do semi-transparent masking is possible.

@ansis
Copy link
Contributor

ansis commented Oct 3, 2013

I'm thinking about this in the context of #77 now. If a draw call draws any fragments that aren't opaque, then it can't be drawn out of order (using the depth buffer). It might make sense to draw anti-aliasing separately for all features so that we can take advantage of depth culling and sorting.

I think polygon anti-aliasing could be nicely drawn using the depth buffer (instead of the stencil buffer). One call which draws the main polygon and writes to the depth buffer. A second call that draws anti-aliasing and avoids the main polygon through depth culling. Most of the fragments in the second call will be depth culled, so theoretically this should perform better than the current approach.

@ansis
Copy link
Contributor

ansis commented Oct 3, 2013

... and I just realized that we need the stencil buffer for concave polygons, so much of what I wrote above doesn't apply.

@kkaefer
Copy link
Member Author

kkaefer commented Oct 22, 2013

We already cull the antialiasing fragments that lie inside the polygon. This doesn't seem worth investigating now.

@kkaefer kkaefer closed this as completed Oct 22, 2013
bensleveritt pushed a commit to bensleveritt/mapbox-gl-js that referenced this issue Oct 24, 2016
Rewrite tests - next action: update mapbox#48 with remaining tests
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

No branches or pull requests

2 participants