#Texture bleeding when using a TextureAtlas

3 messages · Page 1 of 1 (latest)

true tendon
#

I got texture bleeding when using a TextureAtlas, can anyone help? I switched to using a TextureAtlas for the spaceship builder game I'm making. I followed the bevy example for this: https://github.com/bevyengine/bevy/blob/latest/examples/2d/texture_atlas.rs

However, now the sprite textures "bleed" over from neighbouring texture areas on the atlas. I could not find a "padding" setting on the atlas builder. Is there a way to solve this issue without having to rework the TextureAtlasBuilder?

GitHub

A refreshingly simple data-driven game engine built in Rust - bevy/texture_atlas.rs at latest · bevyengine/bevy

hot zephyr
#

You can set the texture's filtering to nearest and that should eliminate the lines. After you builder.finish(images) and get the Atlas, do something like rs images.get(atlas.texture).unwrap().sampler_descriptor = ImageSampler::nearest();
I believe MSAA would also cause an issue, so disable that if you have it set.
The easier solution IMO would be to add padding in the texture atlas. For my project, I originally added a method to TextureAtlasBuilder via trait to build the atlas with padding during runtime, but now I build it in a python script during game build. Both approaches are honestly fairly straightforward, and doing it this way eliminates a lot of weird issues I've found.

true tendon
#

That's useful advice, I'll see if I can use the trait approach, sounds like a possibility which suits me. Will report back 🙂