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

Investigate pixelated symbols in labels #6863

Closed

Description

@mikemorris

Platform: Ubuntu 16.04 with NVIDIA closed-source GPU driver version 367.27
Mapbox SDK version: master

Steps to trigger behavior

When rendering tiles from mapbox/streets-v8 in MapMode::Still, some label icons appear pixelated.

  • London mapbox/streets-v8/tiles/17/65502/43585@2x
    • center: [ -0.092010498046875, 51.50617819737356 ]
  • New York City mapbox/streets-v8/tiles/17/38592/49273@2x
    • center: [ -74.00253295898438, 40.72748642299778 ]
  • Changing the decimal precision of the lat/lng centerpoint can affect the artifacts, sometimes fixing them if precision is trimmed enough. However, trimming centerpoint precision does not fix all instances of this artifact, and in some cases makes it worse. Is there a potential float precision issue here and if so how should it be handled?

master

43585 2x 3

trimmed to 8 decimal places

43585 2x 2

1f7d29b4-9f71-11e6-8fd7-717bf4c70bec

Expected behavior

Label icons are rendered without pixelation or fuzziness artifacts.

bec71b9c-9f71-11e6-868b-69ffb17f86e5

Actual behavior

Label icons are pixelated (Villa Mosconi, Emmet's, The Dutch).

49273 2x

/cc @jfirebaugh @brunoabinader @kkaefer @samanpwbb

Activity

  1. added
    Core
    on Oct 31, 2016
  2. jfirebaugh commented on Oct 31, 2016

    @jfirebaugh
    Contributor

    My hunch is that the artifact happens when this OpenGL implementation is asked to sample a texture with GL_NEAREST interpolation and texture coordinates that are exactly on a half-texel boundary. I believe that in that case, this implementation sometimes rounds the texture coordinates up and sometimes rounds down.

    In particular, I've seen it in the Annotation unit tests when I had an annotation placed at null island using an image with an odd width. In that case, there was a vertical line artifact looking very similar to the ones above. Once I switched to an even width image, the problem went away.

    To test this theory, I think we could try modifying the symbol_icon shader to round v_tex coordinates in a consistent way here. If this works, then a complete fix would involve providing a way for the shader to know if GL_NEAREST or GL_LINEAR interpolation was being used, and do the rounding only in the GL_NEAREST case. Does this sound viable @ansis / @kkaefer?

  3. ansis commented on Oct 31, 2016

    @ansis
    Contributor

    Does this sound viable @ansis / @kkaefer?

    If it works it is viable!

    In particular, I've seen it in the Annotation unit tests when I had an annotation placed at null island using an image with an odd width. In that case, there was a vertical line artifact looking very similar to the ones above. Once I switched to an even width image, the problem went away.

    Internally all images are padded so that their dimensions are multiples of 4 pixels. Unless this is broken, I'd guess the even vs odd didn't matter as much as it being a different width.

    My hunch is that the artifact happens when this OpenGL implementation is asked to sample a texture with GL_NEAREST interpolation and texture coordinates that are exactly on a half-texel boundary. I believe that in that case, this implementation sometimes rounds the texture coordinates up and sometimes rounds down.

    It could also be that the the varying interpolation produces a v_tex that is sometimes slightly on one half and sometimes slightly on the other half. The texture interpolation itself would consistently pick a side, it would just get slightly off values as input. If this is the case, I think we might need to do the rounding in the vertex shader.

  4. brunoabinader commented on Oct 31, 2016

    @brunoabinader
    Contributor

    complete fix would involve providing a way for the shader to know if GL_NEAREST or GL_LINEAR interpolation was being used, and do the rounding only in the GL_NEAREST case.

    This heuristic sounds promising - though we'd need to pass an extra bool in shader code?

  5. mikemorris commented on Nov 1, 2016

    @mikemorris
    ContributorAuthor

    For reference, after the partial GL_LINEAR revert in #6866, label icons appear to be rendered with GL_NEAREST in MapMode::Still, yielding the renders below. These aren't necessarily better or worse, just different - is this intentional and which mode would be preferable in this case?

    17/65502/43585@2x

    43585 2x

    17/38592/49273@2x

    49273 2x

  6. mikemorris commented on Nov 2, 2016

    @mikemorris
    ContributorAuthor

    git bisect landed on f03afde (overscaledZ) as responsible for the differing pixelation visible in the images above, doesn't have anything to do with GL_LINEAR or GL_NEAREST. Didn't start git bisect far enough back.

    The change responsible for this slight rendering difference was reverted in #6876. We're now back to the pixelation visible in the original post.

  7. jfirebaugh commented on Nov 2, 2016

    @jfirebaugh
    Contributor

    That means there's an uncontrolled variable in your bisect test. f03afde will only affect collision tile debug box rendering. It has no effect on icon rendering.

  8. jfirebaugh commented on Jan 4, 2017

    @jfirebaugh
    Contributor

    I'm seeing this now even on retina iOS:

    image

  9. self-assigned this
    on May 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CoreLinux

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions