godotengine / godot

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

Vulkan: GPUParticles3D angular velocity has jumps #49767

Closed QbieShay closed 1 year ago

QbieShay commented 3 years ago

Godot version

v4.0.dev.custom_build [1acc76fec]

System information

Linux Arch, Radeon RX 590

Issue description

Enabling angular velocity results in the particle angle to abruptly jump during the particle lifetime

https://gfycat.com/difficultweebrontosaurus

Steps to reproduce

Minimal reproduction project

No response

Calinou commented 2 years ago

@QbieShay Can you still reproduce this on 4.0.alpha8? Also, can you reproduce this after setting Fixed FPS to 0 on the GPUParticles3D? If not, this might be due to the same cause as https://github.com/godotengine/godot/issues/51318.

QbieShay commented 1 year ago

Still observing strange jumps as of RC2. unfa in rocket chat had a way to repro the issue.

akien-mga commented 1 year ago

CC @unfa. Moving to 4.x for now as it's unlikely to be fixed this week.

Calinou commented 1 year ago

I can't reproduce this on 4.0.rc3 when using angular velocity + particle billboard in both 2D and 3D after setting Fixed FPS to 0 and disabling Interpolate.

It should be noted that angular velocity does nothing if not using Particle Billboard, which I find a bit surprising. Edit: This is probably related to https://github.com/godotengine/godot/issues/49766.

Minimal reproduction project: test_particle_angular_velocity.zip

2D

https://user-images.githubusercontent.com/180032/220712278-9f8e3563-4be8-4dab-b2dd-3a312d504d78.mp4

3D

There's an initial stray particle at the center that stays until its lifetime ends. This is a GPUParticles3D bug that doesn't occur in 2D.

https://user-images.githubusercontent.com/180032/220712290-4c22a254-8c76-4a8b-9f48-f3a46518fe34.mp4

unfa commented 1 year ago

I am not sure if this is the same bug, or a different one, but it's been affecting me since the beginning of Godot 4:

All I did here was added randomized angle and damping.

Particle Rotation Jolt.zip

The first frame of a particle existing has a different angle than next one the middle of the motion, and once damping brings the particle to a complete stop, the angle is changed again. The expected behavior here is the particle orientation to be constant throughout it's lifespan.

SSR-2023-02-23_02.19.57.webm

This "first frame is different" is something that still makes particles sometimes cover the whole screen, be emissive and have weird colors and generally try to trigger photosensitive epilepsy. It used to be so bad I had to stop using particles at all for some time, and then slowly start with CPU particles because the issue was less pronounced with them.

QbieShay commented 1 year ago

I have the same with random angle. I feel like there's some strange stuff happening between the moment a particle dies and the moment it is respawned after. I took a video of what I was experiencing (and i could fix it by fading in the particle later).

I am not sure what it is. I have tried making changes to the particle shader (for example angle is not taking into account the lifetime, but it takes directly CUSTOM.y which ignores random lifetime) but even fixing that doesn't fix the issue of the angle. I think it's a discrepancy on how particle data is handled. It doesn't even look like it's an issue with particle index because even when using a constant number for the random, it still shows.

https://user-images.githubusercontent.com/7917475/227797287-3208b7bd-d4bd-4a10-9249-9a1e30de46dc.mp4

QbieShay commented 1 year ago

This is in 4.0 stable ^

clayjohn commented 1 year ago

Taking a look into this.

The base angle is stored in CUSTOM.x in the start() function: https://github.com/godotengine/godot/blob/d4dad2b2f88968ff329145f3dab5290478bae886/scene/resources/particle_process_material.cpp#L473-L474

Then it is updated in the process() function: https://github.com/godotengine/godot/blob/d4dad2b2f88968ff329145f3dab5290478bae886/scene/resources/particle_process_material.cpp#L740-L742

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

QbieShay commented 1 year ago

Thank you Clay!