Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Support polygon blurring #192

Merged
merged 16 commits into from
May 26, 2014
Merged

Support polygon blurring #192

merged 16 commits into from
May 26, 2014

Conversation

kkaefer
Copy link
Member

@kkaefer kkaefer commented May 26, 2014

screen shot 2014-05-12 at 12 38 54 pm

For outdoors hillshades. Ideally this is a blur property that takes a pixel value.

@edenh edenh added the outdoors label May 12, 2014
@kkaefer
Copy link
Member

kkaefer commented May 13, 2014

#140 is a prerequisite for this.

@incanus incanus added this to the WWDC milestone May 14, 2014
@incanus
Copy link
Contributor

incanus commented May 14, 2014

I have added this to the WWDC milestone. Let's get all the relevant Outdoors-labeled issues there for easier tracking if the goal of #171 getting Outdoors working is part of the WWDC launch.

@kkaefer
Copy link
Member

kkaefer commented May 16, 2014

Cross-referencing mapbox/mapbox-gl-js#236

@kkaefer
Copy link
Member

kkaefer commented May 26, 2014

There are still a lot of things that need to be done; I created separate tickets for these:

@kkaefer kkaefer merged commit 3a9f353 into master May 26, 2014
@mourner mourner deleted the blur branch May 26, 2014 15:59
@incanus
Copy link
Contributor

incanus commented May 26, 2014

Do we need the blur properties to be transitionable?

@edenh
Copy link
Contributor Author

edenh commented May 26, 2014

@incanus not necessary for transitioning between WWDC styles, but nice to have otherwise.

@incanus
Copy link
Contributor

incanus commented May 26, 2014

Ok. #252 (non-WWDC).

@incanus
Copy link
Contributor

incanus commented May 26, 2014

@gundersen blur side-by-side for context (click for full):

blur

@gundersen
Copy link

wow. This is so close. @nickidlugash @edenh - thoughts on matching the darkness of the hill shades?

@gundersen gundersen mentioned this pull request May 27, 2014
@edenh
Copy link
Contributor Author

edenh commented May 27, 2014

The issue currently is that blurring is applied uniformly at all zoom levels. Supporting zoom-aware functions for blurring (#253) should get this near perfect.

@incanus
Copy link
Contributor

incanus commented May 27, 2014

I'll take a crack at that shortly then @edenh.

@kkaefer
Copy link
Member

kkaefer commented May 27, 2014

@edenh The blurring is already somewhat zoom-aware: It appears more blurred the further you zoom in, and appears less blurred the more you zoom in. As explained in #253 (comment), this isn't an easy thing to fix for now (we can revisit this later on). It looks like this is only a slight visual deviation from Mapnik's look, but please reopen a ticket if it's not and this is more urgent.

@edenh
Copy link
Contributor Author

edenh commented May 27, 2014

@kkaefer here are a few comparisons. The blur is currently too aggressive and actually ends up degrading the quality a bit. If we can't hit functions, could we at least set a min zoom for the blur property (~14-15)?

Original
screen shot 2014-05-27 at 9 31 04 am
With blur
screen shot 2014-05-27 at 9 30 40 am
Without blur
screen shot 2014-05-27 at 9 43 32 am

For these low zoom levels, I prefer the crispness without blur. Another example:

With blur
screen shot 2014-05-27 at 9 40 39 am
Without blur
screen shot 2014-05-27 at 9 39 33 am

@nickidlugash
Copy link
Contributor

For reference, the carto outdoor style starts hillshade polygon blurring at z14:

at z14 --> image-filters: agg-stack-blur(2,2);
at z15–16 --> image-filters: agg-stack-blur(8,8);
at z17–18 --> image-filters: agg-stack-blur(16,16);
at z19 and above --> image-filters: agg-stack-blur(32,32);

kkaefer added a commit that referenced this pull request May 28, 2014
@kkaefer
Copy link
Member

kkaefer commented May 28, 2014

The way blurring works is by rendering everything to a texture, then blurring the texture, then upscaling the texture to fit the tile. Currently, the texture is 256x256 pixels, which when upscaled looks very blurry. You have these options to control the blurring:

  • prerender-size: The texture size (default 256).
  • prerender-buffer: The buffer in percent around the tile that we should render too. This should be identical to the amount the data in the vector tile exceeds the vector tile's bounding box. (default 1/32 = 0.03125)
  • prerender-blur: Number of blurring rounds performed.

With a prerender-size of 512, the hillshades look like this:

screen shot 2014-05-28 at 06 33 02

Previously:

screen shot 2014-05-28 at 06 33 23

@edenh
Copy link
Contributor Author

edenh commented May 28, 2014

Ok. Setting the buffer size to 1024 generally helps if we cannot contain the blur to specific zoom levels, but I think 512 after z14 would be much better.

@kkaefer
Copy link
Member

kkaefer commented May 28, 2014

@edenh What we can do is have function properties that are fixed to integer zoom levels, e.g. they wouldn't smoothly interpolate between zoom levels as you zoom in and out, but we could use stops to define values for integer zoom levels. Does that sound useful?

@edenh
Copy link
Contributor Author

edenh commented May 28, 2014

Yes, that would be fine. We would probably want to minimize the amount of 'jumps' in blur to one or two at ~ z14 and 17 in that case.

Would this just look like a stops function on the prerender-size property?

@nickidlugash
Copy link
Contributor

I think this could work, since the complexity of hillshade polygons and density of contour lines change at integer zoom levels anyway.

@edenh
Copy link
Contributor Author

edenh commented May 30, 2014

@kkaefer any chance you can hit stops for polygon blurring today?

@kkaefer
Copy link
Member

kkaefer commented May 30, 2014

@edenh I will implement this tomorrow (Sun) morning.

@edenh
Copy link
Contributor Author

edenh commented May 31, 2014

@kkaefer great. It will also be useful for some of the overlay work.

@mikemorris
Copy link
Contributor

Curious if any techniques from http://www.sunsetlakesoftware.com/2013/10/21/optimizing-gaussian-blurs-mobile-gpu would be applicable here to increase performance?

@kkaefer
Copy link
Member

kkaefer commented Aug 11, 2014

We're already doing that:

I used OpenGL's native support for linear interpolation to downsample the source image by 4X in width and height, blurred that downsampled image, then linearly upsampled via OpenGL afterward

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

Successfully merging this pull request may close these issues.

6 participants