Skip to content

Support inner glow effect on fill layers #769

Open

Description

@peterqliu

To simulate drop shadows.

Activity

  1. ajashton commented on May 13, 2015

    @ajashton

    Depending on how this is implemented, it may make sense to think about tint bands in the same way. These are basically the non-blurry version of an inner-glow.

    Also, depending on the layer, a drop-shadow/outer-glow property would also be desirable.

  2. samanpwbb commented on May 14, 2015

    @samanpwbb
    Contributor

    @kkaefer word on the street is that you have an implementation for this in mind. Do you think you could lay out the next actions (even if real work on this is still a ways away)

  3. kkaefer commented on May 15, 2015

    @kkaefer
    Member

    I'm seeing two ways of implementing this: either via signed distance fields, or via gaussian blur. SDFs are harder to create, but will potentially look nicer than blurs. Gaussian blurs might be a good compromise, since they're faster to compute than SDFs.

    Tint bands are difficult with both techniques since the killer feature for tint bands is the ability to color every band differently, which means we'd have to create a separate blur/SDF per feature, which isn't viable.

  4. ajashton commented on May 15, 2015

    @ajashton

    Different colors per tint band are important for some things but not always necessary. Eg they are also commonly used for boundaries of national parks / nature reserves, in which case you would only need 1 color per layer.

  5. kkaefer commented on May 18, 2015

    @kkaefer
    Member

    Rendering inner glows with gaussian blur seems possible and looks quite nice:

    screen shot 2015-05-18 at 18 17 49

    Bands on the other hand aren't going to be possible with this technique. For bands to look decent, we'd have to generate a proper signed distance field, or use actual polygon offsetting.

  6. mourner commented on May 18, 2015

    @mourner
    Member

    @kkaefer I see there are noticeable artifacts on tile boundaries, is it easy to fix with the blur approach?

    image

    Also wondering how blur affects performance.

  7. peterqliu commented on May 18, 2015

    @peterqliu
    ContributorAuthor

    @nickidlugash an extra wrinkle in this problem: when using blur for water bodies, does it make sense to use the same blur distance for all sizes of oceans/lakes/rivers? narrow rivers and small lakes won't be wide/big enough to show a non-shadowed shade of blue, and hence will look darker overall.

    If it's indeed an issue, I can't think of a non-complex way to handle these cases.

  8. nickidlugash commented on May 18, 2015

    @nickidlugash

    @nickidlugash an extra wrinkle in this problem: when using blur for water bodies, does it make sense to use the same blur distance for all sizes of oceans/lakes/rivers? narrow rivers and small lakes won't be wide/big enough to show a non-shadowed shade of blue, and hence will look darker overall.

    @peterqliu hmm, same blur distance is how it works in carto, and I think it looks fine (I think it might actually look uglier to have a variable blur distance). In carto styles, I usually style the waterway layers to be the same color as the color around the water edges, not the water color itself.

    @kkaefer that blur test looks great! We get the same rendering artifacts around tile edges in carto/mapnik too – @ajashton is this something we can fix on the data side?

  9. peterqliu commented on May 18, 2015

    @peterqliu
    ContributorAuthor

    Also wondering how blur affects performance.

    @mourner since it's getting blurry anyway, can we smartly simplify the geometry as blur distance increases, in hopes of salvaging some perf savings?

  10. ajashton commented on May 18, 2015

    @ajashton

    We get the same rendering artifacts around tile edges in carto/mapnik too – @ajashton is this something we can fix on the data side?

    There should be enough data in the vector tiles to fix this on the rendering side. The blur edge artifacts are not an issue in Mapnik when you use image-filters-inflate: true; - this renders the blur with the buffer taken into account.

  11. ajashton commented on May 18, 2015

    @ajashton

    same blur distance is how it works in carto, and I think it looks fine (I think it might actually look uglier to have a variable blur distance). In carto styles, I usually style the waterway layers to be the same color as the color around the water edges, not the water color itself.

    +1 agreed

  12. nickidlugash commented on Mar 14, 2016

    @nickidlugash

    @kkaefer is this still something we're considering doing?

  13. jrbowen commented on Mar 16, 2016

    @jrbowen

    @ajashton @nickidlugash tint bands are a major style requirement on many of the maps over here at nat geo. I've worked on getting around the issue but haven't been able to come up with anything - is there anything you guys know of in the meantime that will remove the comp bands around the tile edges?

    screen shot 2016-03-16 at 3 12 14 pm

    screen shot 2016-03-16 at 3 25 35 pm

  14. peterqliu commented on Mar 16, 2016

    @peterqliu
    ContributorAuthor

    @jbowen24 how are you making your bands? Can you link to a live example?

  15. jrbowen commented on Mar 16, 2016

    @jrbowen

    @peterqliu Primarily using the same method described here; https://www.mapbox.com/blog/customizing-geography-class/

    Compositing borders with- image-filters: agg-stack-blur(5,5);
    Knocking out the polygon center with- polygon-comp-op: hard-light;
    Then changing the background's level of black to choose how much color comes through- background-color: #a2a2a2;

    example here; https://api.mapbox.com/v4/jelder.35845870/page.html?access_token=pk.eyJ1IjoiamVsZGVyIiwiYSI6InpCTmhMdm8ifQ.lJcqxcME79NwtzwTNX2qNw#4/-9.54/-34.28

    Is there a better way to go about it so the tile boundaries don't show up?

  16. muesliq commented on Apr 8, 2016

    @muesliq

    +1

  17. changed the title [-]Inner-glow effect on polygons[/-] [+]Support inner-glow effect on fill layers[/+] on Jul 28, 2016
  18. changed the title [-]Support inner-glow effect on fill layers[/-] [+]Support inner glow effect on fill layers[/+] on Feb 21, 2017
  19. added
    cross-platform 📺
    on Feb 21, 2017
  20. muesliq commented on May 31, 2017

    @muesliq

    Any update on this?

  21. kkaefer commented on Mar 13, 2018

    @kkaefer
    Member

    As mentioned in a previous comment, signed distance fields are the way to go here. We could render a low resolution SDF for a layer that allows us to shade both sides of the polygon outlines up to a certain distance. Apart from gradients around borders, this would also enable implementing tint bands, and offset polygons/borders without the caveats of a geometric line offseting/buffering algorithm.

    To reduce the number of shaded pixels, we could use a contouring algorithm like CONREC (C++ impl, h/t @kevinkreiser), GDAL's Polygonize, or Marching squares (e.g. d3 impl) to obtain a polygon of the part of the tile we're interested in, and only draw those fragments. This helps in areas that don't have many polygons, e.g. when drawing water in a continental area where there are only small lakes, rivers, or shorelines visible.

    @muesliq, please note that this doesn't mean that we're going to implement this any time soon, I'm just collecting thoughts. We're happy to accept contributions.

    /cc @natslaughter

  22. ifzm commented on Oct 10, 2019

    @ifzm

    Highlighting the plot will make the map look better and look forward to this feature.

  23. bagirimana commented on Jun 9, 2020

    @bagirimana

    I think this feature could greatly improve the aesthetics of many Mapbox maps, for sure ours, so I hope its development will be continued. 👌

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cross-platform 📺feature 🍏needs discussion 💬

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions