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

Raster tiles aren't perfectly crisp at integer zoom levels #4552

Closed
jaapster opened this issue Apr 6, 2017 · 26 comments · Fixed by #6059
Closed

Raster tiles aren't perfectly crisp at integer zoom levels #4552

jaapster opened this issue Apr 6, 2017 · 26 comments · Fixed by #6059

Comments

@jaapster
Copy link

jaapster commented Apr 6, 2017

I noticed that raster tiles are somewhat blurry when rendered in Mapbox and did some experimenting.

When at a discrete zoom level (e.g. 14) it appears as if the tiles are rendered slightly smaller than the original size in which they were retrieved from the tile service.

Tile as it was received by the browser:
screen shot 2017-04-06 at 15 50 45

Resulting image in the map:
screen shot 2017-04-06 at 15 50 55

Am I correct in assuming that a 256x256 tile is not rendered in 256x256 pixels when at a discrete zoom level?

Once you notice the blurriness of the raster images it is rather annoying.

I'm using version 0.34.0

@Pat28
Copy link

Pat28 commented Apr 6, 2017

Have done some testing as well...and found rendering at level 20 of some google tiles seems to be sharp, while level 12 is quite blurry...this screenshot shows the image zoomed in a lot...
Green is level 20, red is level 12
afbeelding

@jfirebaugh
Copy link
Contributor

I can't reproduce this. At a discrete zoom level, 256px raster tiles are rendered at exactly 256px, with no blurriness. Are you sure you don't have a page zoom factor in effect?

@jaapster
Copy link
Author

jaapster commented Apr 6, 2017

The page is at 100%.

I'm having trouble reproducing the size difference at the moment, but the blurriness is still there.

Original
screen shot 2017-04-06 at 16 55 31

Map
screen shot 2017-04-06 at 16 56 15

The map is at zoom level 14.

@jaapster
Copy link
Author

jaapster commented Apr 6, 2017

I can't reproduce the size difference anymore. I'm not sure what happened there.

Another example of the difference between the original image and how it's rendered at zoom level 18:

Original
screen shot 2017-04-06 at 17 04 32

Map
screen shot 2017-04-06 at 17 05 08

@mourner
Copy link
Member

mourner commented Apr 6, 2017

@jaapster are you looking at this on a Retina screen? One guess I have is that browsers apply high-quality upscaling algorithms for displaying 2x-scaled images on the screen, while a OpenGL would do a low-quality bilinear interpolation.

@jaapster
Copy link
Author

jaapster commented Apr 6, 2017

@mourner I am looking at this on a Dell Ultrasharp U3415W monitor hooked up to a MacBook pro (2015). Some of my teammates that use PC's are experiencing the same results.

@mourner
Copy link
Member

mourner commented Apr 6, 2017

I'm also wondering whether #4443 could have any effect on this. Could you try this on the master version (not released yet) and see if raster tiles look the same?

@jaapster
Copy link
Author

jaapster commented Apr 7, 2017

Hi @mourner, I tried it on a build of master and the result is about the same

Original
screen shot 2017-04-07 at 13 23 19

As rendered on the map
screen shot 2017-04-07 at 13 23 37

Still blurry

@andrewharvey
Copy link
Collaborator

I can replicate this issue testing https://www.mapbox.com/mapbox-gl-js/example/map-tiles/

@Pat28
Copy link

Pat28 commented Apr 7, 2017 via email

@jaapster
Copy link
Author

jaapster commented Apr 7, 2017

@Pat28 I meant the result shows about the same blurr as I've seen in v0.34.0.

@andrewharvey
Copy link
Collaborator

andrewharvey commented Apr 8, 2017

Tagging this as a bug since we have multiple people noticing the same issue that for an unscaled page (100% zoom) at a discrete zoom level raster tiles are rendered blurry (compared to the raster tile downloaded / stored in the webgl texture; I inspected the texture with WebGL Inspector and it's crisp compared to the rendering).

In this tile, I split on the left whats rendered and on the right what's in the texture/downloaded webp (split through the Boise label).
tile-compare

It happens with satellite too but it's less noticeable.

Interestingly on a device with a devicePixelRatio of 2.25 I don't notice this issue, it looks crisp but on a device with devicePixelRatio of 1 I do. However on the devicePixelRatio of 1 device, if I force using @2x tiles I notice it's still blurry. So appears to be environment specific.

This seems to go back to very early in GL JS versions.

@tyrasd
Copy link

tyrasd commented Apr 12, 2017

Here's another example where mapbox-gl really does not the best job at rendering raster tiles: Compare https://bl.ocks.org/tyrasd/raw/4242194ccfc1c57562944733d10cbf66/#6/27.452/57.220 to https://tyrasd.github.io/osm-node-density/#7/27.452/57.220/latest (Leaflet slippy map)

(via http://www.openstreetmap.org/user/tyr_asd/diary/39009#comment38202 @jenningsanderson)

@jfirebaugh jfirebaugh changed the title Raster tiles always rendered somewhat blurry Raster tiles aren't perfectly crisp at integer zoom levels Sep 27, 2017
@ibesora
Copy link

ibesora commented Oct 25, 2017

Is there an estimation about when will this issue be resolved? We were evaluating MapboxGL to change Leaflet in our map building web app but are facing this same issue, all the raster tiles are much more blurry than on Leaflet to the point of being unusable.

@emreibis
Copy link

Can this issue be set to an higher priority because we do use a lot of raster tiles in our project?

@jenningsanderson
Copy link

jenningsanderson commented Nov 18, 2017

Just adding another example, for what it's worth...
Raster (with mapbox.js / leaflet): http://www.townsendjennings.com/osm-density/index.html#11/39.023/-94.555
mapbox-gl-js: http://www.townsendjennings.com/osm-density/map-vector.html#10/39.0230/-94.5550
(512 x 512 tiles; transparent backgrounds in the tiles)

@andrewharvey
Copy link
Collaborator

Not related to this issue, but just in case anyone searches for blurry tiles and ends up reading this issue, make sure if you're using 256px tiles you have set tileSize: 256 on your source, as that would also cause blurry tiles.

@andrewharvey
Copy link
Collaborator

closed by #6026. Great work @kkaefer 🎉

@gabimoncha
Copy link

gabimoncha commented May 23, 2018

Hi, @andrewharvey @kkaefer @jfirebaugh

I have the same problem. Just started a project in mapbox-gl and using it with react (no wrapper)
I created the style in the studio, but the raster which is a .tif file when added as a layer gets blurry. Also, in the browser they look the same. If I am doing something wrong please tell me. In case it's not the package's fault, can you direct me to some place where this question should be asked?
Here are the screenshots:

.tif file:
image

in the studio:
image

Can you help me solve this problem. If you have questions please do ask

@andrewharvey
Copy link
Collaborator

@gabrielmoncea do you think your issue is #4450? There is a proposed fix for that at #6411 but it hasn't been merged into a release yet.

@kkaefer
Copy link
Contributor

kkaefer commented May 23, 2018

@gabrielmoncea how are you adding the TIFF file? Mapbox GL can't natively read TIFF files, so there's a good likelihood that one of the intermediary steps introduces these artifacts as well.

@gabimoncha
Copy link

@kkaefer I uploaded the files as GeoTIFFs. sorry my bad.

@riastrad
Copy link

@gabrielmoncea How are you preprocessing the GeoTiff prior to uploading it as a Tileset? The upload pipeline sometimes has trouble with unusual (anything not 256px) block sizes and this can cause the tiles to be be blurry, but you can usually get around this by specifying the GeoTiff's block size prior to uploading.

For example, using GDAL via the command line you can run a command similar to the following:

gdal_translate -co BLOCKXSIZE=256 -co BLOCKYSIZE=256 input.tif output.tif

@gabimoncha
Copy link

gabimoncha commented May 26, 2018 via email

@riastrad
Copy link

@gabrielmoncea for large GeoTiff files we recommend a block size of 256x256.

See: https://www.mapbox.com/help/uploads/#tiff-uploads

@mathieurudaz
Copy link

I have the exact same problem and even after executing
GDAL_Translate -of GTIFF -ot BYTE -scale 0 1 0 255 -co TILED=YES -co BLOCKXSIZE=256 -co BLOCKYSIZE=256 -b 1 -a_nodata 0 input.tif output.tif my raster is blurry in Mapbox studio.

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

Successfully merging a pull request may close this issue.