Skip to content

raster-resampling has no effect on raster tiles (eg. nearest neighbor is still blurry) #7331

Closed

Description

@robhawkes

mapbox-gl-js version: v0.49.0

browser: Chrome 69.0.3497.92 (Windows 64bit)

Steps to Trigger Behavior

  1. Set up a basic map instance with a raster tile layer
  2. Set the raster-resampling paint property of the raster tile layer to nearest
  3. Over-zoom map and notice blurry tiles

Link to Demonstration

http://jsbin.com/nohuromeqa/1/edit?js,output

Expected Behavior

According to the documentation, when setting the raster-resampling paint property to nearest the raster tiles should have sharp pixels when over-zoomed.

Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled

Also, when changing the raster-resampling paint property to linear the results should appear different.

Actual Behavior

When setting the raster-resampling paint property to nearest the raster tiles have blurry pixels when over-zoomed.

When changing the raster-resampling paint property to linear the results appear the same (blurry).

Screenshots with custom layer (not in demo)

Over-zoomed in QGIS

2018-09-25 08_48_02-_untitled project - qgis

Over-zoomed in Mapbox GL JS with raster-resampling set to nearest

2018-09-25 08_49_18-mbtiles raster test

Over-zoomed in Mapbox GL JS with raster-resampling set to linear

2018-09-25 08_49_51-mbtiles raster test

Screenshots from demo

Original tile

174333

Over-zoomed in Mapbox GL JS with raster-resampling set to nearest

2018-09-25 09_09_35-js bin - collaborative javascript debugging

Over-zoomed in Photoshop (1000% increase in size)

2018-09-25 09_02_27-174333 png 100 rgb_8 _

Activity

  1. mourner commented on Sep 25, 2018

    @mourner
    Member

    Interesting! Might be GPU-dependent? Here's how the example works for me on macOS:

    image

    Can you also try different browsers?

  2. robhawkes commented on Sep 26, 2018

    @robhawkes
    Author

    Ah good question, I hadn't checked other browsers and machines yet.

    Here are the results of a few tests:

    • Windows, NVIDIA GeForce GTX 1070
      • Firefox (62.0.2) looks blurry
      • Edge (42.17134.1.0) looks blurry
    • Windows (Surface Book 2), NVIDIA GeForce GTX 1050
      • Chrome (69.0.3497.100) looks blurry
    • MacOS (MacBook Pro Retina, 2012)
      • Chrome (69.0.3497.100) looks pixellated
    • iOS (iPhone 8 Plus)
      • Chrome 69.03497.105 (iOS) looks pixellated

    Looks like Windows vs. MacOS / iOS more than GPU. Are you able to replicate it on a Windows machine?

  3. mourner commented on Sep 26, 2018

    @mourner
    Member

    Hmm, I have no ideas why Windows wouldn't like the NEAREST mag filter. Perhaps you could poke around the code and see if there are any clues? https://github.com/mapbox/mapbox-gl-js/blob/master/src/render/draw_raster.js#L48

  4. robhawkes commented on Sep 26, 2018

    @robhawkes
    Author

    Me neither, I'll see if I can find a moment to have a look and poke around.

    If it helps, the Three.js examples using a nearest mag filter work as expected (pixellated) on Windows: https://threejs.org/examples/webgl_materials_texture_filters.html

    image

  5. andrewharvey commented on Sep 26, 2018

    @andrewharvey
    Collaborator

    It's passing in the render tests which run on Linux, and I can't replicate this on my Linux machine either, so certainly it being a Windows specific issue sounds plausible.

  6. added
    needs investigation 🔍
    on Sep 27, 2018
  7. Scarysize commented on Dec 4, 2018

    @Scarysize

    I can also confirm this issue. I validated that both MIN & MAG texture filters are set to NEAREST using the WebGL Inspector Chrome Extension. This only happens on Windows, no issues on macOS:

    image

    Instead of blur, we get rainbowy edges, as we remap grey scale colors of the original tile image.

  8. Scarysize commented on Dec 4, 2018

    @Scarysize

    I did some digging, and from what I can gather, the problematic lines are here:

    if (context.extTextureFilterAnisotropic) {
    gl.texParameterf(gl.TEXTURE_2D, context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, context.extTextureFilterAnisotropicMax);
    }

    If commented out, everything looks fine on my side.

  9. SnailBones commented on Oct 28, 2022

    @SnailBones
    Contributor

    I'm hitting this while implementing #12268, not only on Windows but also on MacOS VM.

    This issue can be fixed on Mac by using Chrome flag --use-gl-desktop as introduced in #10389, however that causes a separate set of tests to fail with missing globe and inconsistent stars. (Same or similar test failures that led to #12090)

    windows-raster-resampling

    A likely related issue appearing In the same circumstances: icons appear to have incorrect resampling.
    windows-icon-offset-literal

  10. michaelagal commented on Jul 12, 2024

    @michaelagal

    Has anyone found a solution to this issue? I've tried versions 1.6 and version 2.8 and in both cases "nearest" raster-resampling is not working on Windows. It works on Linux/iOS (including on Android).

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

    bug 🐞environment-specific 🖥️needs investigation 🔍

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions