godotengine / godotengine/godot
Camera2D pixel position all over the place (jittery) in scaled subviewport with pixel snapping
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in: v4.2.2.stable.official [15073afe3]
### System information
Godot v4.2.2.stable - Windows 10.0.22631 - GLES3 (Compatibility) - AMD Radeon(TM) Graphics (Advanced Micro Devices, Inc.; 31.0.21912.14) - AMD Ryzen 5 5500U with Radeon Graphics (12 Threads)
### Issue description
When I make my camera follow a CharacterBody2D, even without position smoothing, the character's position keeps jittering back and forth. When analyzing the footage frame by frame, I was able to see that the character's position sometimes, and only sometimes, snaps one pixel off-center.
https://github.com/godotengine/godot/assets/82157205/0ab6cd9d-21a7-4825-86b0-984ea7aebff6
Also, I'm using the `move_and_slide()` function inside the _process() function instead of the _physics_process() function, but there doesn't seem to make a difference (I'm talking about the jitter, I know the difference between these two I think.). The jitter still persists, although it does seem be a little bit better.
It's weird because I've never encountered an issue like this when using Monogame or GameMaker. Is there a workaround for this?
Am I just being stupid?
Thanks!
### Steps to reproduce
-Create a scene with Camera2D that follows a CharacterBody2D
-Put the scene inside a subviewport container with a very low-res, then scale it to fit the window.
-Enable pixel snapping in the subviewport container.
When you move your CharacterBody2D, its position will sometimes snap to an adjacent pixel, making it jittery...
### Minimal reproduction project (MRP)
[BugReportPixelCamera.zip](https://github.com/user-attachments/files/15793030/BugReportPixelCamera.zip)
Contributor guide
Assessment
This issue has not been assessed yet.