-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
TextureAtlasBuilder padding #9494
TextureAtlasBuilder padding #9494
Conversation
Adds a `padding` method to `TextureAtlasBuilder` that can be used to set an amount of padding to add between the sprites of the generated texture atlas.
Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once we clarify the docs: the field docs are great, but aren't publicly exposed so it's helpful to repeat them.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
It might also be good to expand the texture atlas builder example in another PR. |
# Objective `TextureAtlas` supports pregenerated texture atlases with padding, but `TextureAtlasBuilder` can't add padding when it creates a new atlas. fixes bevyengine#8150 ## Solution Add a method `padding` to `TextureAtlasBuilder` that sets the amount of padding to add around each texture. When queueing the textures to be copied, add the padding value to the size of each source texture. Then when copying the source textures to the output atlas texture subtract the same padding value from the sizes of the target rects. unpadded: <img width="961" alt="texture_atlas_example" src="https://github.com/bevyengine/bevy/assets/27962798/8cf02442-dc3e-4429-90f1-543bc9270d8b"> padded: <img width="961" alt="texture_atlas_example_with_padding" src="https://github.com/bevyengine/bevy/assets/27962798/da347bcc-b083-4650-ba0c-86883853764f"> --- ## Changelog `TextureAtlasBuilder` * Added support for building texture atlases with padding. * Adds a `padding` method to `TextureAtlasBuilder` that can be used to set an amount of padding to add between the sprites of the generated texture atlas. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Objective
TextureAtlas
supports pregenerated texture atlases with padding, butTextureAtlasBuilder
can't add padding when it creates a new atlas.fixes #8150
Solution
Add a method
padding
toTextureAtlasBuilder
that sets the amount of padding to add around each texture.When queueing the textures to be copied, add the padding value to the size of each source texture. Then when copying the source textures to the output atlas texture subtract the same padding value from the sizes of the target rects.
unpadded:
padded:
Changelog
TextureAtlasBuilder
padding
method toTextureAtlasBuilder
that can be used to set an amount of padding to add between the sprites of the generated texture atlas.