You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
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
trimmed to 8 decimal places
Removing GL_LINEAR mode rendering changes the style of artifact, fixing some but introduces others (fuzziness visible in RBBTS icon).
Expected behavior
Label icons are rendered without pixelation or fuzziness artifacts.
Actual behavior
Label icons are pixelated (Villa Mosconi, Emmet's, The Dutch).
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?
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.
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?
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?
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.
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.
Activity
jfirebaugh commentedon Oct 31, 2016
My hunch is that the artifact happens when this OpenGL implementation is asked to sample a texture with
GL_NEARESTinterpolation 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_iconshader to roundv_texcoordinates in a consistent way here. If this works, then a complete fix would involve providing a way for the shader to know ifGL_NEARESTorGL_LINEARinterpolation was being used, and do the rounding only in theGL_NEARESTcase. Does this sound viable @ansis / @kkaefer?ansis commentedon Oct 31, 2016
If it works it is viable!
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.
It could also be that the the varying interpolation produces a
v_texthat 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.brunoabinader commentedon Oct 31, 2016
This heuristic sounds promising - though we'd need to pass an extra bool in shader code?
mikemorris commentedon Nov 1, 2016
For reference, after the partialGL_LINEARrevert in #6866, label icons appear to be rendered withGL_NEARESTinMapMode::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
17/38592/49273@2x
mikemorris commentedon Nov 2, 2016
. Didn't startgit bisectlanded on f03afde (overscaledZ) as responsible for the differing pixelation visible in the images above, doesn't have anything to do withGL_LINEARorGL_NEARESTgit bisectfar 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.
jfirebaugh commentedon Nov 2, 2016
That means there's an uncontrolled variable in your
bisecttest. f03afde will only affect collision tile debug box rendering. It has no effect on icon rendering.jfirebaugh commentedon Jan 4, 2017
I'm seeing this now even on retina iOS:
Slightly move center of text-font/chinese test to avoid render errors
Slightly move center of text-font/chinese test to avoid render errors