-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Stabilize snapping 2D transforms to pixel #87297
Stabilize snapping 2D transforms to pixel #87297
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
a955862
to
8968e4d
Compare
This comment was marked as resolved.
This comment was marked as resolved.
3532649
to
5055d51
Compare
aad6666
to
acad6d6
Compare
a607f8f
to
76913a7
Compare
Just tested with both pixel perfect test projects, and both look as expected. |
70437ba
to
25fc819
Compare
Co-authored-by: Danni <[email protected]>
25fc819
to
35b6401
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great research everyone!
Let's give this a spin and see how pixel art users like it in the next dev snapshot (4.3-dev4).
Thanks! |
A bit late to the party, but I have the feeling that instead of Consider this: We position a sprite at x=0.5, which is snapped to x=1 on screen. We move it to the left by 1px. Where should the sprite be at on screen? The expectation should be x=0. However, since the subpixel position is now x=-0.5, the sprite is actually snapped to x=-1 on screen thanks to rounding. Which means the supposedly 1px move becomes a 2px move on screen. |
tl;dr
This PR simplifies greatly the snapping of 2D transforms to pixel. Instead of relying on flooring sprites, CanvasItems (so twice flooring for sprites) and the camera transform, this PR only rounds each CanvasItem position.
Co-authorship
This PR is heavily inspired by #84380 by @KeyboardDanni, so I added them to the commit as co-author.
Why?
There's some issues with pixel perfect both due to:
Superseding
floor()
withround()
in pixel snap to transform #84380Tests
floor()
withround()
in pixel snap to transform #84380 PixelPerfectTest.zip#84380 test
master
master.webm
This PR
87297.webm
Merlin: Scale of the Magic
(author note: the project was edited to add debug info)
master
master.webm
This PR
87297.webm
Production edit: closes godotengine/godot-roadmap#79
Bugsquad edit: