-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Bevy 0.5 Sprite Sheet Animation Sprite Leak #1949
Comments
I could not reproduce, either using your code or trying a smaller example 😞 |
Hmm could you both share your graphics cards (and driver if relevant) |
I have updated my repo to have the latest 0.5 changes so you can try it out without checking out to a different branch: https://github.com/selfup/ionized_earth_rpg GPU: 1660ti Currently on 461.72 - Going to upgrade to 466.11 Edit: Same issue with new driver. Rust version and target info on Windows 10:
Tried 1080p max window, same issue. Fine when window is in the original size. Let me know if you need any additional information! |
I'm able to repro on my computer (nvidia gtx 1070, arch linux, proprietary drivers), but only if I vertically resize the window. Some vertical scales produce the artifacts (identical to the screenshot above), and others don't. This bug is identical to one that this commit resolved, which was later removed. Re-adding that offset resolves the issue in |
Not sure if I'm understanding the source of the problem correctly.. but if it's the surrounding sprites bleeding into the current one then I think 1px of transparent padding and |
I'm running into the same issue. Win 10, last updates, Nvidia RTX 2060, drivers 511.79. The issue is happening regardless of window resize and of sprite size. The leaking edge is not always the same, depending on the position of the sprite. I made a video with adjacent tiles colored pink: out.mp4Any idea how we could help to track down this issue? |
Yeah padding sprite sheets is a "generally accepted" resolution to this. I'd like to sort out a fix for unpadded sheets, but resolving these rounding errors has been pretty nasty (and sometimes platform specific?). As mentioned in StarArawn/bevy_ecs_tilemap#123, one option is to move to a texture array representation internally, but off the top of my head idk what the full implications of that move would be. For example, im pretty sure the array would need each layer to be the same size, so each sprite would need to take up the space of the "largest" sprite in the array. TextureAtlases can be more "compressed". Pulling in @StarArawn as this is relevant to what they're doing. |
I meant to say something about pixel perfect cameras which can also help with these things especially reducing floating point inaccuracies for 2D games. |
Gentle ping about this since the 0.6 renderer rework landed since this issue was opened. Is this still desirable/reproducible? |
I have upgraded bevy to 0.6 then 0.6.1 and I still have the issue on Windows when maximizing the window. I'll have to check on my other machines. This seems to affect different GPUs/OSs differently so I was just confirming that my initial report is still accurate. Thanks for asking! |
Just as FYI, the issue has been reported in a discussion a few days ago: #4424 and i've also run into it separately. There was also a brief exchange on discord |
Thank you for the cross reference! |
An update: I’m trying to make some progress on this because in my opinion it has a relatively high impact for 2D games using sprite sheets. At the same time I'm definitely not über knowledgeable, which makes things tricky at best. After some discussion on Discord with Rob Swain and Nical it seems that the general agreed upon solution is (quote):
which is what Webrender does. As Rob said (quote):
My understanding is that sprite offset and sprite size (for sprites from texture atlases) is not data available in the sprite shader (it is shared for all sprites, regardless if they come from an atlas or not). Is this correct? If that’s correct (it might not be), it leads to these possibilities, and i’m not sure what’s best:
What are your thoughts on this? Is the above accurate? Thanks a lot |
As the information is only needed for texture atlas sprites it feels like there should be a way to make a uniform for that case and only use it in that case. Coming up with a good overall solution will need a bit more thought that I don’t have time for in this moment. I’ll try to remember to revisit this but if I forget, poke me on Discord. |
Another bit of info about my report above: My desktop has a little bit of scaling applied to it, for making things a little bit bigger. So, I don't know if it's my desktop scaling that triggers this, but in my Bevy game, if I don't set a |
hey just maybe worth noting that I did not have this issue on 0.5.0, but did with 0.7.0 and 0.8.0 |
I think it's very device specific and small tweaks to shaders can fix it in one place and break it in other places so that might be what's happening between Bevy 0.5 and the later versions on your graphics card. I've submitted fixes for this on a couple Bevy tilemap renderers that have seemed to work ( StarArawn/bevy_ecs_tilemap#197 & forbjok/bevy_simple_tilemap#7 ). I also might be able to do a better version without branching in the shader, but I'll have to test it out. If I get the chance I'll try to see what fixing this in Bevy's sprite renderer might look like. |
I can confirm this issue is still present in latest (0.11) System |
I experience this as well. I mitigated the issue very slightly by adjusting padding with It's affected by zooming the projection's scale. Sometimes the lines disappear from specific areas when I zoom in/out. WASM/Chrome testing generated from an x86_64-unknown-linux-gnu build. |
I was able to sufficiently mitigate this issue for my use case without modifying the underlying assets. Here's my current understanding just in case it helps anyone going forward.
Consider the sprite sheet below. It is one column of 16 sprites. Each sprite is 128x128. 15 of the sprites have a thick, black border along one or more of their edges. There is no padding between them. The "correct" way to generate a texture atlas from this asset is: texture_atlases.add(TextureAtlas::from_grid(
texture_handle,
Vec2::splat(128.0),
1,
16,
None,
None,
)) However, this exhibits the undesired bleed effect. For my scenario, this occurs with these settings:
Here is how this renders. Note the black border bleeding into various sprites. Also note that if I resize the window then the affected sprites change. Now, consider an adjusted call to texture_atlases.add(TextureAtlas::from_grid(
texture_handle,
Vec2::new(128.0, 120.0),
1,
16,
Some(Vec2::new(0.0, 8.0)),
Some(Vec2::new(0.0, 4.0)),
)) Here I keep my x-axis as-is because I am working with a single column sprite sheet. I reduce the size of my sprite along the y-axis, then add an equal amount to y-padding (not half!), and add half the amount to y-offset. Here is the result: This eliminates the bleed artifacts. Note that using a sufficiently large reduction in The final solution was to work my way down through reduced UPDATE: As my awareness of this issue increases, so does the length of this post :) I ended up moving away from a homegrown tilemap solution for performance reasons. My 144x144 tilemap crashed on my test iOS device where it did not crash before the introduction of sprite sheets. The lowest hanging fruit performance fix was to adopt "meshing" in which multiple sprites are combined into larger mesh chunks. This functionality is implemented already in
After talking with the maintainer of app.insert_resource(Msaa::Off); This fixed my bleed issue without any padding hacks. So, I would encourage others to use this approach first and only to explore more complex, padded solutions afterward. |
Bevy version
bevy = "0.5"
Operating system & version
Windows 10
Can test on Ubuntu 20.04 as well as MacOS Catalina
What you did
Upgrade to Bevy 0.5 from 0.4
What you expected to happen
Expect sprite sheet animation to work the same as before
What actually happened
Once upgraded, when I full screen the window the sprite animation has artifacts from another position in the sprite sheet
Additional information
Here in my
player_setup.rs
: https://github.com/selfup/ionized_earth_rpg/blob/main/src/systems/player_setup.rs#L13This now has to be changed to:
To avoid the other sprite from leaking in.
Here is a small screenshot of the feet leaking in above the player. Looks like two black bars:
Short video showing the artifacts leaking through when moving around.
2021-04-17.01-59-52.mp4
The text was updated successfully, but these errors were encountered: