-
-
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 does not pad the textures #8150
Comments
On the flip side of this I've noticed that when using a texture atlas with spacing (which I do for 2d tile map games) and default_nearest, at some zoom levels it picks the border pixels leaving my game with many vertical and horizontal lines. I read about some artifacts coming out of MSAA however turning it on and off seems to have no impact, pretty sure it's in the texture atlas somewhere. I'm using bevy 0.11.0 and seeing the same issue in both windows vulcan and wasm |
That's why some people also "bleed" the sprites one or two pixel into the padding. So for example, 4 pixels for padding and 1 pixel for bleeding. |
Yes, I guess I could solve it that way. It's probably even possible to write a bit of code that takes the input tile-map (I'm not an artist I'm just using CC free stuff) spaces it out more and just duplicates the pixels on the borders. Still probably won't look 100% pixel perfect, which makes me a little sad, but will be a lot better than the mesh of flat window background colour. Thanks for the tip. |
I have a crate that implements an alternative It hasn't been updated for a while because some changes in 0.10 broke my TextureAtlas crates, 0.11 reversed those changes though. It's really simple and you can probably fork it and update it yourself, or you can wait; I plan to put aside an afternoon next week to update my third-party crates (at least the useful ones). |
# Objective `TextureAtlas` supports pregenerated texture atlases with padding, but `TextureAtlasBuilder` can't add padding when it creates a new atlas. fixes #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, 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>
Bevy version
0.10.0
Relevant system information
What I did
ImagePlugin::default_linear()
.TextureAtlasBuilder
.Additional information
This is most likely caused by lack of padding in the atlas texture, causing linear filtering to accidentally sample from other sprites.
The text was updated successfully, but these errors were encountered: