-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Remove 2D transform snapping to rely instead on the GPU #87058
Remove 2D transform snapping to rely instead on the GPU #87058
Conversation
Co-authored-by: Clay John <[email protected]>
@markdibarry @KeyboardDanni I'll try to port PixelPerfectTest.zip to Godot 3.x, if there's issues there too. |
I looked at your commits and it looks like it's just removing the snapping that's applied to all 2D transforms (leaving in the snapping that's done on Sprites). Feels like something is missing here. I would expect changes in the shader code as well if we are to rely on GPU snapping. My understanding is that the GPU snap was only done on the 3.x branch. |
GPU snap is here and its implemented the same as it was in 3.x godot/servers/rendering/renderer_rd/shaders/canvas.glsl Lines 201 to 206 in 9b522ac
The difference is that 3.x removed the transform snapping which is what this PR does. |
That particular code doesn't seem to be doing much snapping, unless something got configured wrong. The third video looks functionally identical to disabling snapping (with the exception of Sprites which are still being snapped). Which is why it seems like something is missing here. |
@clayjohn @KeyboardDanni We were doing this PR thinking that Godot 3.x was doing fine. But I ported your PixelPerfectTest.zip test to Godot 3.x (PixelPerfectTest3.zip). And it seems that Godot 3.x code is failing your test too, @KeyboardDanni. PixelPerfectTest3.mp4 |
Looking at this, I'm wondering if the camera isn't getting snapped to pixel. It looks like the vertices of individual 2D elements are snapped. But you're still going to get jitter if the camera isn't being snapped as well. Technically you could work around this on the script side, but I feel like it'd be better to just have this happen in the shader as part of the vertex snap, so that everything would "just work". I also feel that the way the snap options are presented in settings is a bit confusing. Users might think that you'd need to enable both snap settings (transform and vertex), when really you should only be using one, as having both enabled might cause unforeseen issues. |
Oh my, I didn't enable the 2D snapping in my Godot 3.x test. I'll capture stuff and come back with a video. |
I'd also like to add that if we're going to remove 2D transform snapping, it should be done thoroughly. Remove the project setting, transform snap variables, etc. Replacing the transform snapping mode with a no-op would only make things more confusing for users. |
cc @lawnjelly since they've worked on this stuff for 3.x and might have some insight. |
Here's Godot 3.5.2 running PixelPerfectTest3 using GPU snap (failing the test too). PixelPerfectTest3-snapped.mp4 |
@KeyboardDanni @markdibarry I've sent you private chat messages on https://chat.godotengine.org/. I'm currently organizing a meeting next week to talk about pixel perfect rendering issues. I think you'd be welcome to join and share your insight with us. |
Superseded by #87297. |
More or less applies #46657 to the
master
branch (4.x). It fixed issues on 3.x, but wasn't forward-ported in 4.x.This PR removes the need of rounding brought by #84380. As the GPU is doing the rounding, we don't have to floor the transform values on the DisplayServer side.
Comparison
Merlin: Scale of the Magic
Using the open-source pixel perfect game Merlin: Scale of the Magic by @nicolasbize.
w/o this PR
GodotRoundVsFloor-floor.mp4
w/ this PR
fixed.mp4
#56793
w/o this PR
w/ this PR
Relates to
Supersedes #84380.
Fixes #56793.
Fixes #84632.