godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.7k stars 20.12k forks source link

Interpolate in GPUParticles makes particles stutter when paused at high FPS. #65390

Open MewPurPur opened 2 years ago

MewPurPur commented 2 years ago

Godot version

4.0.alpha15

System information

Ubuntu 22.04.1 LTS

Issue description

https://user-images.githubusercontent.com/85438892/188526773-358bc500-d248-4c1d-8f3a-88b9847d4b3f.mp4

With high-speed particles the issue is the most evident.

Steps to reproduce

Create a GPUParticles2D and add a process material, make the particles high-speed, increase project FPS (possibly by turning VSync off) and pause the game.

Some observations:

Minimal reproduction project

Didn't have time to make one, but I'll get to it later if it'd help.

Calinou commented 2 years ago

Related to https://github.com/godotengine/godot/issues/50824 and https://github.com/godotengine/godot/issues/51318.

To work around this, disabling Interpolation and setting Fixed Fps to 0 (or a very high value such as 1000) seems to do the trick.

elvisish commented 1 year ago

Related to #50824 and #51318.

To work around this, disabling Interpolation and setting Fixed Fps to 0 (or a very high value such as 1000) seems to do the trick.

This works in beta 10. I can confirm it's still not working beta 10, my refresh rate is 165 and it's jerky (30fps looking) if interpolation is on.

Mickeon commented 11 months ago

I have stumbled upon this issue recently. The workaround looks quite trivial, so it'd be nice to fix this soon instead of having to do apply it for every particle node...

Calinou commented 11 months ago

The workaround looks quite trivial, so it'd be nice to fix this soon instead of having to do apply it for every particle node...

There's a PR changing the default, but reduz would prefer we fix interpolation (which is nontrivial): https://github.com/godotengine/godot/pull/70777

Mickeon commented 11 months ago

Oh, but in my project I temporarily disable interpolation when the GPUParticles node is paused (by checking for NOTIFICATION_PAUSED/UNPAUSED), and that's all. Setting the fixed FPS to 0 doesn't seem to matter to me. Perhaps something has changed after a year?

Robert-K commented 2 weeks ago

I feel like the engine should just internally disable the interpolation if the particles are paused. They're not gonna move anyways, right?

Mickeon commented 2 weeks ago

Disabling interpolation on pause would, in theory, make the particles instantly snap to their actual position, which would look jarring. Therefore the solution may not be as straightforward as assumed.

Robert-K commented 1 week ago

Not seeing any jarring jump. It's certainly better than epilepsy introducing jittering ;) For anyone stumbling on this, here's a quick script you can attach to your particles (make sure the 2D/3D matches) to fix the jittering for now:

extends GPUParticles2D

func _notification(what):
    match what:
        NOTIFICATION_PAUSED:
            interpolate = false
        NOTIFICATION_UNPAUSED:
            interpolate = true