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

Inconsistent transparency for multiple fill-extrusions #5288

Closed
kekscom opened this issue Sep 14, 2017 · 3 comments
Closed

Inconsistent transparency for multiple fill-extrusions #5288

kekscom opened this issue Sep 14, 2017 · 3 comments

Comments

@kekscom
Copy link

kekscom commented Sep 14, 2017

Refers to mapbox-gl-js 0.40.0
Likely rendering fill extrusions in common 3d space is involved:
#5101

Adding more than 2 fill-extrusion layers causes different transparency behaviour than for first 2.

Steps to Trigger Behavior

  • fill-extrusion layers 1+2 blend and transparency is applied to result
  • subsequent fill-extrusion layers do not blend with others but at least 3d space is correct

Expected Behavior

A: Either all fill-extrusion layers get transparency applied separately or
B: All fill-extrusion layers are blended and then transparency is applied. Guess this is intended and preferred.

screenshot 2017-09-14 10 11 42

@lbud
Copy link
Contributor

lbud commented Sep 18, 2017

Right — what you're seeing is based on layer order:

  • Layer 1 is rendered to an offscreen texture.
  • Layer 2 is rendered to an offscreen texture with knowledge of the depth values of Layer 1, and some fragments, which would be visible with only this layer rendered, are dropped due to failing depth testing in relation to already-rendered values in layer 1. However, fragments that overlap with layer 1 fragments and pass the depth test are rendered.

Then in the main (translucent) rendering pass,

  • Layer 1's offscreen texture is rendered back to the map at desired opacity. No further depth testing is done to discard fragments in relation to layer 2, so some fragments that are "behind" layer 2 are rendered anyway and will be visible if layer 2 is translucent.
  • Layer 2's offscreen texture is rendered back to the map at desired opacity.

It's possible we could fix this down the road with clever use of stencil testing, but this may necessitate introducing more rendering passes and it's hard to say if/when this will be prioritized.

@lbud
Copy link
Contributor

lbud commented Sep 18, 2017

(In the meantime, this can be mitigated by potentially being strategic about layer order, or otherwise reducing the number of layers by using data-driven styling, which is always preferable for performance reasons.)

@kekscom
Copy link
Author

kekscom commented Sep 19, 2017

I did not notice even my layer 2 (green roof) is transparent for buildings because of effective height of 0. With that in mind behaviour is consistent through all extrusion layers.
I think this is acceptable.
Thank you!

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

3 participants