0 votes

So I have 2 options I've found to zoom:
- use shrink = 4 in the project settings,
- use camera zoom = 0.25 in the camera node

While the shrink option gives sprites a nice pixel perfect aligned look, it makes the camera (with custom smoothing) jitter, because the camera seems to snap to the pixels as well.

The camera zoom option removes any jitter, but causes the sprites to not align with the pixel grid anymore, and thus causes some weird quarter pixel lines and stuff, which i'd like to avoid.

So, does anyone know a way to get the best of both worlds??
pixel snapping for sprites, but allowing the camera to move at sub pixel increments.

thanks in advance


in Engine by (21 points)

1 Answer

+1 vote
Best answer


I figured it out.

so first
Project setting: stretch = 1
Camera: zoom = 1

Make a new scene:
-ViewportContainer (vpc)
--Viewport (vp)
--- scene with your camera (sc)

vp: size = the size you want (viewport size/zoom factor + 1 to remove ugly lines on the sides)
vpc: scale = upscaling you want

camera: script:
keep a position variable (pos)
all smoothing goes into this var
for the actual position
camera.position = floor(pos)

vpc: script
var x = cam.pos.x - cam.position.x
var y = cam.pos.y - cam.position.y
rectposition.x = -int(floor(x * 4))
position.y = -int(floor(y * 4))

That's it

Hope this helps anyone with the same problems.

by (21 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.