Open timbess opened 2 years ago
We have existing padding support already. Checkout the tile spacing field here: https://github.com/StarArawn/bevy_ecs_tilemap/blob/main/src/layer.rs#L47
A better solution to this problem is to not rely on texture atlases which are prone to bugs like this. In the far distant future, when I get some time, bevy_ecs_tilemap
will no longer support atlases directly and instead internally everything will use a texture array instead. This will allow us to use texture filtering as well as mip maps which will great increase the quality of tilemap rendering when zooming.
@StarArawn Yeah I tried adding padding in that field and it seems to completely mess up the sampling at that point.
This is what happens when I add Vec2::new(1.0, 1.0)
of spacing.
I would suggest we look at fixing this in the new renderer since it involves only fixing 1 spot. I can try to look at this tonight. 🤔
Thanks! I'll try to look into it too, but I'm a noob with graphics programming and bevy internals for that matter. Very cool what you've done here though, way better than my naive approach when I did it manually.
I have the same issue
I noticed while adjusting the camera's scale that there is an issue with the sampling when zoomed in at different levels. Seems to happen mostly when zoomed out:
It seems like this line was an attempt to fix it:
https://github.com/StarArawn/bevy_ecs_tilemap/blob/d7c4f8c8aa7775061f38aaf22bf2040610012f31/src/render/square-tilemap.vert#L113
Back when I tried to implement this myself, this seemed to fix my problem (adding 1px of padding to the textureatlas): https://github.com/bevyengine/bevy/issues/1949#issuecomment-825637328
So I expect the padding calculations done here will fix the bug: https://github.com/bevyengine/bevy/blob/de8edd3165c379e05aabb38359b3f4b97f46540a/crates/bevy_sprite/src/texture_atlas.rs#L125-L159