Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPUParticles2D animated particles with random offsets stutter between frames when emitted #79515

Closed
project-flytrap opened this issue Jul 15, 2023 · 5 comments · Fixed by #80984

Comments

@project-flytrap
Copy link

project-flytrap commented Jul 15, 2023

Godot version

v4.1.1.rc1.official [e709ad4]

System information

Godot v4.1.1.rc1 - Windows 10.0.22621 - Vulkan (Compatibility) - Intel(R) UHD Graphics 620 (Intel Corporation; 30.0.101.1338) - Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 Threads)

Issue description

When a GPUParticles2D has a random animation offset, particles appear to suddenly switch between frames when the particles are first emitted.

CPUParticles2D do not exhibit this behavior, they exhibit what we'd expect. (Particles start on the random frame and do not change)

In the video, CPUParticles2D is on the left, and GPUParticles2D is on the right. Note the stuttering on GPUParticles2D when the particles are first emitted/spawned.
https://github.com/godotengine/godot/assets/77651264/bba15e03-a0c0-4ca0-a4d1-7b2353fb092b

This behavior is also exhibited when the project is run in debug mode.

Godot_v4.1.1-rc1_win64_A2vZtt2z8w.mp4

Notable Observations:
Setting anim_offset_min and anim_offset_max to equal values does not exhibit this stuttering behavior.
I discovered this bug in 4.1 stable while trying to pinpoint another visual bug with GPUParticles2D.

Steps to reproduce

  1. Create a GPUParticles2D node
  2. Give it a texture
  3. Give it a CanvasItemMaterial, set particles_animation to on, and set either particles_anim_h_frames or particles_anim_v_frames to an integer value greater than 1.
  4. Give it a ParticleProcessMaterial, set anim_offset_min and anim_offset_max to unequal values.

Minimal reproduction project

ParticleAnimationOffsetIssueMRP.zip

@Calinou
Copy link
Member

Calinou commented Jul 15, 2023

Can you reproduce this with Interpolate disabled and Fixed FPS set to 0 on the GPUParticles2D? See #59072.

@project-flytrap
Copy link
Author

Can you reproduce this with Interpolate disabled and Fixed FPS set to 0 on the GPUParticles2D? See #59072.

Yes, the behavior persists with these changes, both in editor and in debug

@clayjohn
Copy link
Member

This reminds me of #49767

It could be another issue with calculating random values

@greycheeked
Copy link

Since I'm just getting into the subject, here's what I noticed.
In start():
CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, anim_offset_rand);

And in process():
CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, rand_from_seed(alt_seed)) + tv * tex_anim_speed * mix(anim_speed_min, anim_speed_max, rand_from_seed(alt_seed));

Just like you said with the other issue:

Note how angle_rand is used the first time, but the second time a new random amount is generated

Only this time it's about anim_offset_rand.

@clayjohn
Copy link
Member

Since I'm just getting into the subject, here's what I noticed. In start(): CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, anim_offset_rand);

And in process(): CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, rand_from_seed(alt_seed)) + tv * tex_anim_speed * mix(anim_speed_min, anim_speed_max, rand_from_seed(alt_seed));

Just like you said with the other issue:

Note how angle_rand is used the first time, but the second time a new random amount is generated

Only this time it's about anim_offset_rand.

Ah yes, the rand_from_seed functions need to be called in the same order in both start() and process() otherwise the value will jump like here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants