#Parallax Scrolling is jittering

73 messages · Page 1 of 1 (latest)

limber zodiac
#

I've been battling this issue for a while, and originally blamed it on the renderer. However, the issue now occurs with all three renderers. The game is running smoothly, but the parallax background scrolling is jittering. Sometimes it's only a little bit, sometimes it's really bad. It looks like the image is jittering back and forth while scrolling. When I record it, it doesn't seem as bad, but I do see that, when it jitters, instead of advancing each frame, it doesn't advance for 2 frames, and then advances twice its distance.
The code for the scrolling is simply:

func _process(_delta):
scroll_offset.x -= 10

The problem is that this makes the scrolling background function pretty much unusable. I tried using _physics_process() instead, but that didn't help either.

UPDATE: Further testing has shown that keeping the background still and moving a camera instead produces the same jitter. It doesn't even need to be parallax. Just creating a background out of a few texture rects is enough. What is going on here? Is Godot incapable of smooth movement?

UPDATE 2: After a bit more digging, might be an issue with the Nvidia graphics card. I made a test project, built it and ran it on my PC, jittery mess. I then ran it on a laptop with an Intel UHD Graphics, runs perfectly smooth. Interestingly, when I run the executable while also running OBS, it gets less jittery. And when I record, even less. I guess my graphics card is too powerful for Godot or something?

ripe jolt
#

Beginner myself here, but on my projects most jittering issues I have had were related to frame and/or physics synch issues. Doing things like messing with vsynch, FPS settings, proper use of delta, physics calculations, or interpolation are what fixed mine. Are you already using these ideas on your witch movement and such?

limber zodiac
#

The witch is not moving at all, in this video. Only the background is scrolling passt.

ripe jolt
#

Might try lerping the background scroll vs a straight move

limber zodiac
#

I have no idea what that means, I'm afraid.

ripe jolt
#

and/or see if using delta in your move calculation helps

velvet pecan
#

You should be multiplying the factor you are offsetting the background by delta to allow for variations in the timing that _process is called.

limber zodiac
#

If this is a timing issue... wouldn't putting it in _physics_process solve that? I mean, _physics_process is reliably ticking 1/60 seconds, isn't it?

ripe jolt
#

^ i would try that first. just multiply the move calculation by "delta" - dont forget to change the argument in your process

#

i think that is true for phyics calulation but it wont account for changes in time to render a frame

limber zodiac
#

Okay, so how do you mean with delta? I don't suppose you mean
scroll_offset.x -= scrolling_speed * delta
right?

ripe jolt
#

yes, something like that. but keep in mind you might have to increase your offset a good bit

#

and make sure you change your: func process (delta) vs (_delta) since you will actually be using delta now

limber zodiac
#

Okay, that doesn't really work. It stays extremely slow, and the speed won't change, no matter how much I increase the scrolling_speed. Had it up to 1000000, same as at 10.

limber zodiac
ripe jolt
#

do you have it in process or physics process now?

limber zodiac
#

Okay, so
scrolling_speed * delta
is always 0.08333333333
no matter what scrolling_speed is

#

Tried that now, same effect. It's always 0.083333333333

#

Ah, yes, of course. Because it's an integer. Changed it to float. Jitter still occurs.

ripe jolt
#

which function do you have it in now and where do you actually move the background?

limber zodiac
#

This is the current script:

@export var scrolling_speed: float = 250.0

func _process(delta):
scroll_offset.x -= scrolling_speed * delta

I also tried with _physics_process, no difference.
The script is attached to a ParallaxBackground node, which has a ParallaxLayer child, which has the background in a TextureRect as a child.

ripe jolt
#

let me look at one of my projects where i used that node, i dont remember exactly how it works

#

func _process(delta):
scroll_offset.x -= delta * GameManager.SCROLL_SPEED -- haha ya my calculation was exactly same as yours

#

scroll speed 120

velvet pecan
#

You are exporting the scrolling_speed variable. Have you been changing the value in the Inspector? That will override what you have put in the script.

ripe jolt
#

same setup as you a scene with para background and layers as children

#

i dont think so let me dbl check

#

oh for him

#

haha

limber zodiac
#

I exported it to change it on the fly, but it's actually unnecessary. I changed it directly in the script the last few times.

ripe jolt
#

just to try

#

take the export off and change it directly in the script

limber zodiac
#

I did. No change.

ripe jolt
#

do a print statement before and after the offset calc maybe? scrollspeed: zyx, delta: abc

#

might try turning vsync on in projects settings as well, just see if it makes a difference

#

also did you say you had a texture rec as a child of the para layer?

limber zodiac
#

Okay, first of all, did you mean that with the print?
scrolling_speed: 250 | delta: 0.01666666666667 | calculation: 4.16666666666667
scrolling_speed: 250 | delta: 0.01666666666667 | calculation: 4.16666666666667
scrolling_speed: 250 | delta: 0.01666666666667 | calculation: 4.16666666666667
scrolling_speed: 250 | delta: 0.01666666666667 | calculation: 4.16666666666667
scrolling_speed: 250 | delta: 0.01666666666667 | calculation: 4.16666666666667

ripe jolt
#

my layers accepted the background in the inspector vs another node

limber zodiac
#

Also, vsync is on.

#

Has been on all the time.

#

And yes, it's a TextureRect. How else would I get a background in there?

ripe jolt
#

that might be why then, that and/or max fps would keep it locked as long as you hit max fps

#

a property of the layer i think

limber zodiac
#

No, you added the image via script

ripe jolt
limber zodiac
#

And I just tested all settings of vsync, no changes

ripe jolt
#

right

#

@export var texture: Texture

#

on script attached to the layer, not sure if it will matter or not. just looking at what we have different

limber zodiac
#

Hm, you must have a function that adds the texture into the scene. It won't do that on its own.

ripe jolt
#

ya:

#

@onready var sprite_2d = $Sprite2D

@export var texture: Texture

limber zodiac
#

You put it in a sprite.

ripe jolt
#

sprite_2d.texture = texture

#

then i scale the sprite to window size

limber zodiac
#

Hm. So essentially you just do what I do, just you add the node through script on runtime.

#

That is jittering as well... this really seems to be an issue with the scrolling.

ripe jolt
#

ugh

#

there just isn't much to it, your calculation is identical to mine but i don't have any jitter

limber zodiac
#

I never noticed anything like that in Godot 3... I wonder if I should downgrade. I'll have to adjust all my scripts, but still.

ripe jolt
#

i have had to use lerping to fix it with a fast moving ball etc

#

but seems excessive for this simple application

#

i gotta help wife with dinner, will check back here later. maybe one of the pros here can give you an idea

limber zodiac
#

It's either that or completely rebuild how my levels work. Which is not less work.

#

Okay. Thanks.

ripe jolt
#

there should be a simple fix for this, your approach seems correct.

#

gl, will check back later

limber zodiac
#

ok

limber zodiac
#

Okay, this is driving me absolutely NUTS! I figured if the parallax scrolling isn't working, I don't scroll but move a camera instead. It's also jittering! What the heck is going on here?

rugged musk
#

I've had some weird jittery stuff going on but not with parallax backgrounds, but with various other stuff in my projects. I fixed it by changing the Process Callback in my camera node to Physics instead of Idle. No idea if that'll solve your issue but thought it might be worth trying.