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
Combine multiple sprites into a single texture atlas #10027
Comments
I wanted to use either guillotiere or etagiere for general texture -> texture atlas preprocessing, not just for sprites / sprite sheets. Discussed this a bit with nical (Mozilla dev working on UI stuff as far as I know) on Discord in the Atlas allocation thread in #rendering-dev https://discord.com/channels/691052431525675048/1152646466788134912 |
Ah yeah, those both look good. I wrote some utilities for manipulating texture atlases last year for a 2D game I was working on but they didn't run during gameplay so performance didn't really matter. The way we handle font texture atlases in Bevy is really terrible, maybe guillotiere could help? We want all the glyphs with the same font and font size to share the same atlas obviously but maybe with guillotiere we could dynamically insert and remove multiple sets of glyphs from different fonts together into single atlases. I've avoided tackling any of this because I don't have that much experience with rendering and the UI and text systems always have new non-rendering issues for me to work on. |
What problem does this solve or what need does it fill?
You have two sprite sheets
16 16x16 sprites
4 32x32 sprites
For both convenience and performance, you would like to load the two sprite sheets individually and then have Bevy combine them into a single texture atlas. But unfortunately, Bevy only supports loading homogeneous sprite sheets from a single source image.
What solution would you like?
A method that allows you to take two (or more) sprite sheets and combine them into a single texture atlas:
Rough sketch of a possible API:
Prior art: I wrote this function a while that merges multiple existing texture atlases:
It has problems though:
pub(crate)
. This wouldn't be a problem if it's added to the bevy_sprite crate.merge_atlases
, which isn't ideal.A more ambitious implementation could chop up the sprite sheets and then add the sprites individually into a
TextureAtlasBuilder
. This would allow you to add padding to unpadded source sprite sheet images and might reduce the size of the output texture atlas.The text was updated successfully, but these errors were encountered: