Closed forbjok closed 3 years ago
Many users have problems with camera2D lag in Godot. I spent a lot of time on project settings. Used all camera setup options. Tried to fix the delays with code. It was all unsuccessful. Godot has long had problems with this, and they are not corrected. The only thought I came up with was to use Unity. It's a pity, but until this problem is solved, it makes no sense to use the Godot engine.
@Grizzly-pride Before my fix was pulled there was one 3.x version released including it. You could always give it a try to see if that would fix your problems; it certainly did for me.
I'm willing to give this a try again at some point because it's a deal-breaker for too many people, myself included. I've already seen people remake projects in Unity because the customers didn't like the objects and the maps not being in sync, and that's a pity because if someone spends time to learn Godot and has to switch to Unity it's going to be difficult to convince them to take the step back because of fear of having to spend the time again for nothing. This is by far the worst issue Godot has.
An alternative solution for now is to avoid relying on built-in Camera2D smoothing (or only use it to a minimal amount). The kind of smoothing Camera2D performs (asymptotic smoothing) is not something that was used in 90s pixel art games anyway – assuming you're going for that kind of aesthetic :slightly_smiling_face: It's possible to write your own custom Camera2D smoothing with linear interpolation, which will never slow down to very low speeds that make this issue obvious.
Using the 2d
stretch mode instead of the viewport
stretch mode will also help make this issue less noticeable at higher resolutions.
I'm not trying to discourage anyone from resolving this issue, but I wanted to state again that workarounds do exist.
I think I ran into this in v3.4.4 on Linux. The Pixel Snap setting seemed to fix it but I don't completely understand what causes this and I'd like a bit more information if anyone can provide it.
Strangely enough it only happened with very specific sprites. I tried all of the following:
It does not seem to be relat4ed to the order that sprites are added to the scene, or any pattern I was able to find.
@superlazyname
Strangely enough it only happened with very specific sprites.
Maybe try comparing Sprites with odd and even number of texture side length. If that's the cause, try disabling the "centered" property of the Sprite.
Can't remember the exact conditions right now but if memory serves me well this bug manifests when sprites are not in exact integer positions, i.e. try setting one sprite at X = 10.1 other at X = 25.2 other at X = 40.3... Then move the camera slowly in X and you can start crying. I think camera zoom affected this, too. One 3.x version was released with my PR but unfortunately some other bugs manifested (IMHO latent bugs that were brought to light when the sprites stopped jittering) and in the end the PR was pulled. I'm still willing to try to integrate the PR again but right now I can't devote the time required to find the other bugs that manifested. I think it would be a good idea to add an option and let the user decide. Sprites just can't jitter, and, again IMHO, this issue gives Godot a very bad image. I still think this is by far the worst issue this engine has right now.
I found this problem still exist at the v4.2.1.stable version.
https://github.com/godotengine/godot/assets/12682063/5d73763f-0809-4f48-ba9d-20160f7e4cbd
I found this problem still exist at the v4.2.1.stable version.
For future reference, this occurs because the project isn't using physics interpolation. This means the player sprite is moving at a different frequency than the screen is being rendered at, which will cause visible jitter. To resolve this, you need physics interpolation. 2D physics interpolation will be available in 4.3: https://github.com/godotengine/godot/pull/88424
Until 4.3 is released, you can use https://github.com/lawnjelly/smoothing-addon (also for 3D).
Regarding the original issue, this was improved a lot in 4.3 too: https://github.com/godotengine/godot/pull/87297
I found this problem still exist at the v4.2.1.stable version.
For future reference, this occurs because the project isn't using physics interpolation. This means the player sprite is moving at a different frequency than the screen is being rendered at, which will cause visible jitter. To resolve this, you need physics interpolation. 2D physics interpolation will be available in 4.3: #88424
Until 4.3 is released, you can use https://github.com/lawnjelly/smoothing-addon (also for 3D).
Regarding the original issue, this was improved a lot in 4.3 too: #87297
I'm using a custom build with Physics Interpolation available. I have it switched on, and it is still jittering exactly as it is described in the opening post.
I'm using a custom build with Physics Interpolation available. I have it switched on, and it is still jittering exactly as it is described in the opening post.
Please open a new issue with a minimal reproduction project attached. Also, make sure the stretch scale mode is set to integer
: https://docs.godotengine.org/en/stable/tutorials/rendering/multiple_resolutions.html#stretch-scale-mode
Godot version: 3.1.2 stable, GitHub master (3.2), Vulkan branch (4.0)
OS/device including version: Windows 10 x64 v1909
Issue description: Pretty much as soon as I made my test level larger than a single screen, I noticed something was off. After a bit of testing, I've found out what it is. It seems like any time the camera moves, there is some sort of inconsistency in the positions sprites are being rendered at, causing them to "jitter" back and forth by one pixel even though the camera is only moving in one direction.
Example gifs showing the issue:
How noticeable it is depends on circumstances. Generally, from what I've found, it's most noticeable if you have camera smoothing turned on and the smoothing speed set to a very low value, but the problem isn't related to the camera smoothing. It's also present with camera smoothing turned off, just harder to notice.
In case it was a bug that had already been fixed, I tried compiling Godot myself from both the master (presumably what will become 3.2) and vulkan (4.0?) branches to try them out, but unfortunately the problem still seems to be present in both of those. It looks a bit different in the Vulkan branch, due to what I assume is some sort of smoothing/blur filter being applied (there may be a way to turn that off, but I couldn't find it) to the background, but it is definitely still there.
Steps to reproduce:
Minimal reproduction project: godot-jitter-repro-project.zip