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

Increase sprite atlas capacity #489

Closed
peterqliu opened this issue Oct 16, 2014 · 10 comments · Fixed by #9213
Closed

Increase sprite atlas capacity #489

peterqliu opened this issue Oct 16, 2014 · 10 comments · Fixed by #9213
Labels
Core The cross-platform C++ core, aka mbgl GL JS parity For feature parity with Mapbox GL JS

Comments

@peterqliu
Copy link
Contributor

"fill-image" fails when image >510px on either dimension

@jfirebaugh
Copy link
Contributor

fill-image is already supported. Are you seeing a specific issue with it?

background-image: #394

@peterqliu peterqliu changed the title support for "fill-image" and "background-image" add support for "fill-image" and "background-image" Oct 17, 2014
@peterqliu peterqliu changed the title add support for "fill-image" and "background-image" "fill-image" fails when image >510px on either dimension Oct 17, 2014
@peterqliu
Copy link
Contributor Author

After some tinkering, I've found the issue. fill-image works reliably up til the image is 510px in either dimension. Beyond that and it will not render.

In this example, the water pattern is sized at 510x510, and shows on both browser and native. However, the forest pattern (greenish one over land) is 510x511, and does not show on native.

cc/ @jfirebaugh @incanus

@incanus
Copy link
Contributor

incanus commented Oct 17, 2014

Does it look ok in the sprite?

@peterqliu
Copy link
Contributor Author

@incanus yup

@jfirebaugh
Copy link
Contributor

The sprite atlas has a hard-coded size of 512x512, and images are padded by 2 pixels on a side, so 510 is indeed the current magic number.

In order to fix this properly we need to auto-grow the atlas size when it overflows. A quick fix would be double or triple the current dimensions.

@samanpwbb
Copy link
Contributor

👍 for tripling the dimensions.

@1ec5 1ec5 changed the title "fill-image" fails when image >510px on either dimension Increase sprite atlas size beyond 512×512 Sep 14, 2015
@1ec5 1ec5 added bug GL JS parity For feature parity with Mapbox GL JS labels Sep 14, 2015
@incanus
Copy link
Contributor

incanus commented Sep 14, 2015

There are GL texture implications here to which @kkaefer or @adam-mapbox could likely speak. We need to go with a safe, conservative max texture size across iOS and Android.

@jfirebaugh
Copy link
Contributor

triple the dimensions

I've since learned that we can't increase the size beyond 1024x1024 without changing how sprite alas coordinates are packed in vertex attributes. (Icons are aligned to multiples of 4 pixels, each coordinate is divided by 4, packed into a single byte, and multiplied by 4 in the shader.)

@1ec5
Copy link
Contributor

1ec5 commented Jan 26, 2016

#3703 increases the SpriteAtlas size to 1024×1024.

@samanpwbb
Copy link
Contributor

samanpwbb commented Aug 5, 2016

I'm recommending users to create sprites that are 1360 × 400 at @2x in this tutorial: https://www.mapbox.com/blog/location-based-game-map/, which may be the cause of why maps made with this tutorial are rendering incorrectly:

2016-08-05 10 47 21

If we want to take textures serious we need bigger sprite atlas sizes. 1024 x 1024 is not enough space. Even in the tutorial, the textures feel too small (ideally each individual fill texture is 512 x 512 to reduce how much repetition is apparent to the user.

@jfirebaugh jfirebaugh changed the title Increase sprite atlas size beyond 512×512 Increase sprite atlas capacity Sep 27, 2016
@jfirebaugh jfirebaugh added Core The cross-platform C++ core, aka mbgl and removed bug labels Sep 27, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl GL JS parity For feature parity with Mapbox GL JS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants