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

Remove mipmapping + anisotropic filtering for raster tiles #4580

Open
kkaefer opened this issue Apr 12, 2017 · 2 comments
Open

Remove mipmapping + anisotropic filtering for raster tiles #4580

kkaefer opened this issue Apr 12, 2017 · 2 comments
Labels
GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform performance ⚡ Speed, stability, CPU usage, memory usage, or power usage

Comments

@kkaefer
Copy link
Member

kkaefer commented Apr 12, 2017

We added a call to generateMipMap on a hunch in #112 a few years ago, and it has remained in the raster drawing code ever since. Mipmaps only make sense when the texture is scaled down significantly (way below 50% of its original size), as a mean to improve the quality of the texels used to calculate the fragment color. A few weeks ago, we added anisotropic filtering to improve the quality.

We never added mipmapping for raster tiles in Native, and I don't think we need to, given that we almost always draw the textures in a size that isn't smaller than half the original dimensions. Since we don't mipmap raster tiles, we also don't need anisotropic filtering.

We should remove the call to generateMipMap and consequently remove anisotropic filtering for raster tiles. This should achieve the near identical visual quality while reducing memory usage and making the code less complex.

mapbox/mapbox-gl-native#8688

@kkaefer kkaefer added the GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform label Apr 12, 2017
@andrewharvey
Copy link
Collaborator

Do you propose to use gl.LINEAR/gl.NEAREST? Based on that the current behaviour looks smoother than whan I'm seeing with gl.LINEAR without Anisotropic Filtering.

TEXTURE_MIN_FILTER = gl.LINEAR_MIPMAP_NEAREST with Anisotropic Filtering (master)
selection_558

TEXTURE_MIN_FILTER = gl.LINEAR without mipmaps without Anisotropic Filtering
selection_555

TEXTURE_MIN_FILTER = gl.LINEAR_MIPMAP_NEAREST without Anisotropic Filtering
selection_557

TEXTURE_MIN_FILTER = gl.NEAREST without mipmaps without Anisotropic Filtering
selection_556

@kkaefer
Copy link
Member Author

kkaefer commented Apr 24, 2017

Ah interesting; I was developing this from a GL native side, and didn't add mipmapping, which means anisotropic filtering has no effect, so I concluded that it doesn't have an effect. When comparing the images, you'll notice that anisotropic filtering + mipmapping only has an effect when the image is scaled down by more than 50% (in the upper half of the image). The ideal solution would be to make the mipmap generation conditional, and only start generating mipmaps and render with anisotropic filtering when we tilt the map, and render without mipmaps and anisotropic filtering otherwise.

@mourner mourner added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

No branches or pull requests

3 participants