-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
expose context antialiasing and draw 3d things into main framebuffer #7821
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this subtly changes the way we render fill layers as well since they're now slightly antialiased. We've removed our fake antialiasing using GL_LINE
in #5541, so I guess this is a net-improvement.
StencilMode.disabled, | ||
ColorMode.disabled); | ||
|
||
// Then draw all the extrusions a second type, only coloring fragments if they have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "a second time"
Previously, both fill-extrusions and custom layers were drawn into a offscreen framebuffer before being copied over to the main framebuffer. Drawing directly into the main frame buffer is better because: - it avoids fragment-expensive copies - it unblocks using msaa antialiasing (which only works in the main Drawing opaque extrusions and custom layers involved few changes. Transparent extrusions needed to be implemented differently. They now use a two pass approach: - the first pass only draws depth - the second pass only colors a sufrace if it's depth matches Some tweaks were made to how we draw stencil masks so that we could use the stencil buffer in the second pass to prevent double-shading. The changes should reduce the amount of stencil clears that happen. The way fill-extrusion-opacity works across layers was already kind of weird. This pr makes no attempt to change any of that behaviour. It should be completely backwards compatible.
6cba5b9
to
6ee5daf
Compare
This fixes following issues: * Fix some false passing combinations/fill-extrusion-translucent--XXXX tests * Fix and enable other, failing but ignored, combinations/fill-extrusion-translucent--XXXX tests * Fix rendering of layers that are on top of fill-extrusion layers state.getProjMatrix(nearClippedProjMatrix, 100) caused that tests with size 64x64 were not rendering fill extrusions: far plane calculated as 96.9 and near plane set to 100 was the cause. near plane is changed from hardcoded 100 to depend on state.getCameraToCenterDistance() - producing similar value but one that follows max zoom. This caused that e.g. combinations/fill-extrusion-translucent--fill-opaque was falsely passing as only fill-opaque layer got rendered. combinations/fill-extrusion-translucent--XXXX tests expose regression #14844 (comment) in #14844, #14779. Fix (opaquePassCutoff, is3D) is ported from mapbox/mapbox-gl-js#7821 Fixes: #14844, #14779, #15039
This fixes following issues: * Fix some false passing combinations/fill-extrusion-translucent--XXXX tests * Fix and enable other, failing but ignored, combinations/fill-extrusion-translucent--XXXX tests * Fix rendering of layers that are on top of fill-extrusion layers state.getProjMatrix(nearClippedProjMatrix, 100) caused that tests with size 64x64 were not rendering fill extrusions: far plane calculated as 96.9 and near plane set to 100 was the cause. near plane is changed from hardcoded 100 to depend on state.getCameraToCenterDistance() - producing similar value but one that follows max zoom. This caused that e.g. combinations/fill-extrusion-translucent--fill-opaque was falsely passing as only fill-opaque layer got rendered. combinations/fill-extrusion-translucent--XXXX tests expose regression #14844 (comment) in #14844, #14779. Fix (opaquePassCutoff, is3D) is ported from mapbox/mapbox-gl-js#7821 Fixes: #14844, #14779, #15039
This fixes following issues: * Fix some false passing combinations/fill-extrusion-translucent--XXXX tests * Fix and enable other, failing but ignored, combinations/fill-extrusion-translucent--XXXX tests * Fix rendering of layers that are on top of fill-extrusion layers state.getProjMatrix(nearClippedProjMatrix, 100) caused that tests with size 64x64 were not rendering fill extrusions: far plane calculated as 96.9 and near plane set to 100 was the cause. near plane is changed from hardcoded 100 to depend on state.getCameraToCenterDistance() - producing similar value but one that follows max zoom. This caused that e.g. combinations/fill-extrusion-translucent--fill-opaque was falsely passing as only fill-opaque layer got rendered. combinations/fill-extrusion-translucent--XXXX tests expose regression #14844 (comment) in #14844, #14779. Fix (opaquePassCutoff, is3D) is ported from mapbox/mapbox-gl-js#7821 Fixes: #14844, #14779, #15039
The primary goal is to support antialiasing for custom layers (#7543) by exposing an option to use the context-provided msaa antialiasing. This only works in the main framebuffer so we first need to switch to drawing custom layers an buildings into the main framebuffer. Previously they were drawn into an offscreen framebuffer.
Drawing into the main framebuffer
Drawing directly into the main frame buffer is better because:
New method for transparent fill-extrusions
Drawing opaque extrusions and custom layers involved few changes. Transparent extrusions needed to be implemented differently. They now use a two pass approach:
The way fill-extrusion-opacity works across layers was already kind of weird. This pr makes no attempt to change any of that behaviour. It should be completely backwards compatible.
Stencil buffer changes
I made some tweaks to how we use the stencil buffer so that we could do this. The changes should improve performance as well because we avoid doing expensive stencil clears.
Antialiasing
This fixes #7543 by exposing a new
antialias
map option that is used during gl context creation.Launch Checklist
@kkaefer can you review the first commit with two-pass extrusion rendering and stencil buffer changes?
@mourner can you review the second commit that adds the antialias option