-
-
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
Vulkan: 2D Pixel Snap not working #56793
Comments
Related to #55006. |
Interesting enough the I'm having jittering issues again in 4.0 alpha 1, @lawnjelly any chance this being implemented by default on master too? I'm working on a 2D platformer. Thanks for the work with this addon, @Calinou and @lawnjelly. |
We are currently adding fixed timestep interpolation (what the addon does) to core. |
It's been a while, hopefully this is on someone's plate. If A typical sprite atlas with no padding at the bottom So unlike Godot 3.x, this means at the moment Godot 4 has no solution for pixel perfect games. Hopefully it can be resolved soon. I am including a zip of this example project. |
I did a search for "is_snap_2d_transforms_to_pixel_enabled" and noticed that in I don't know how this will effect collisions for anything though since these are just sprite_2d and animated_sprite_2d. But this might fix an issue I had with odd number sized sprites? I had to give all odd number sized sprites a -0.5 offset. Line 102 if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
dest_offset = dest_offset.floor();
} Line 358 if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
ofs = ofs.floor();
} And in Line 270 if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
ofs = ofs.floor();
} I'm not a programmer and I don't know the inner workings of Godot so if I'm completely off base here, feel free to ignore this. |
Are there any good workarounds to avoid this issue? With Godot 4.1 released and this issue still unresolved, it's challenging to work on pixel-perfect games right now, with seemingly no fix in sight. Edit: I was able to implement a pretty simple workaround, kind of similar to what @svendixon observed. On the This appears to resolve the issue on my end, as I'm no longer seeing sprites being offset and also no longer seeing neighboring pixels on thespritesheet bleeding through. I understand that this might not work for everyone, as it seems that this is a pretty complex issue to resolve for all use cases. |
@huedev You can do as you said, however, if your movement code doesn't work with integers, until 2D Pixel Snap is actually fixed, you should do this: var float_position = 0
func _ready():
float_position = global_position
func _physics_process(delta):
global_position = float_position
#your movement code here
float_position = global_position
global_position = global_position.round() Unfortunately, you'd have to add this code to anything in your game that moves, but it does work. |
@markdibarry Finally had a chance to try this out, it seems to be working well! Since I'm using type hints I had to modify the initial value of |
Fixed by #87297 |
Edit: Sorry, I forgot I was using a Subviewport and had to enable "snap to pixel" there. Still, without the workarounds mentioned I have some jitter of the player (CharacterBody2D) on a moving platform (AnimatableBody2D), while with the workarounds there's no jitter. |
Godot version
4.0dev (ce6de71)
System information
Windows 10, NVIDIA GeForce GTX 960
Issue description
I've seen other issues like this but they're all closed as fixed. I'm still having this issue. Pixels are not snapping correctly with either or both pixel snap options.
1 pixel gap in between collisions.
Steps to reproduce
Create a project with a floor and characterbody2d with basic movement functions, gravity, etc.
Set display stretch mode to
viewport
andkeep
.Enable
Snap 2d Transforms to Pixel
orSnap 2d Vertices to Pixel
or both.Minimal reproduction project
PixelSnapBug.zip
The text was updated successfully, but these errors were encountered: