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

Feature request: make fill-extrusion vertical gradient configurable #5768

Closed
nmccrea-db opened this issue Nov 29, 2017 · 5 comments
Closed

Comments

@nmccrea-db
Copy link

nmccrea-db commented Nov 29, 2017

Hey folks. Thanks for making such an amazing platform.

I'm using mapbox-gl-js 0.42.2. I am representing a stack of blocks on a map using fill extrusions. The problem I'm having is that the lowest blocks are shaded slightly darker than the blocks above them. Here is an example:

funky shading 01

In this example, all four blocks that are pointed out are given the same paint color (in this case, white). But the lowest two are rendered slightly darker than the higher two. Above the first two levels, there are no other inconsistencies.

It appears to have something to do with the elevation of the blocks. For example, if I make the bottom-most block thicker, and thus raise the elevation of the second block, then the inconsistency only affects the first block:

funky shading 02

The problem exists regardless of what color paint is being used:

screen shot 2017-11-29 at 1 04 02 pm

And regardless of opacity:

screen shot 2017-11-29 at 1 03 40 pm

screen shot 2017-11-29 at 1 03 27 pm

This is in a geoJSON layer. The geoJSON is produced like this:

      {
        'type': 'FeatureCollection',
        'features': geometries.map( geometry => ({
          'type': 'Feature',
          'properties': {
            'height':       geometry.height + geometry.baseElevation,
            'base_height':  geometry.baseElevation + VISUAL_SPACE_BETWEEN_BLOCKS,
            'color':        colorForType(geometry.type)
          },
          'geometry': {
            'type': 'Polygon',
            'coordinates': [
              geometry.polygon.concat([geometry.polygon[0]]),
            ],
          },
        }))
      }

And the paint is defined as follows:

{
  'fill-extrusion-color': {
    'type':     'identity',
    'property': 'color',
  },
  'fill-extrusion-height': {
    'type':     'identity',
    'property': 'height',
  },
  'fill-extrusion-base': {
    'type':     'identity',
    'property': 'base_height',
  },
  'fill-extrusion-opacity': 0.9,
};

For my application, the coloring of the blocks is an important visual indicator, so any insight into how I might be able to make the coloring stay consistent would be greatly appreciated.

Thanks in advance.

@stevage
Copy link
Contributor

stevage commented Dec 4, 2017

Have you tried playing with the lighting settings to see if that, um, sheds any light? Does it happen the same when you're only rendering that bottom layer? (Ie, is it affected by the presence of higher levels?)

@lbud
Copy link
Contributor

lbud commented Dec 4, 2017

Currently this is expected behavior; the fill-extrusion shader adds a slight vertical gradient to provide some visual contrast between features (it was originally written primarily with a 3D building use case in mind). I'm going to reframe this ticket as a feature request: I'd be open to adding a paint property to make this configurable.

@lbud lbud changed the title Inconsistent shading on extruded polygons at different elevations. Feature request: make fill-extrusion vertical gradient configurable Dec 4, 2017
@nmccrea-db
Copy link
Author

Thanks very much @lbud. Yes, this would be a useful feature for our case.

@jesus-deepblocks
Copy link

Hi @lbud, I'm following up on this issue. Has this feature been implemented? If not, there is any chance we could have some sort of idea on its ETA and also can you point me in the direction of a workaround in the meantime?

Thanks.

@spimou
Copy link

spimou commented Oct 24, 2022

@nmccrea-db I am trying to achieve the same result on the map like yours, extruding multiple polygons on the same position, one on top of the other. But I cannot get mapbox to do it. Can you please take a look here ? Thanks

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

No branches or pull requests

5 participants