godot icon indicating copy to clipboard operation
godot copied to clipboard

GPUParticles3D linear acceleration doesn't respect velocity direction and causes particles to jitter.

Open viksl opened this issue 1 year ago • 2 comments

Tested versions

4.3

System information

Windows 11 - Vulkan - Nvidia RTX 4070 - intel i5 13600KF

Issue description

Firstly, I don't know if this is a wrong behavior or not so I'm sorry in case I misunderstand how this should work.

  1. If you don't set the initial velocity and only use a (!) positive (!) linear acceleration the particles always accelerate down no matter what velocity direction is set, since the acceleration doesn't have direction maybe it should use the velocity direction? (red particles in the MRP)
  2. If you don't set the initial velocity and only use a (!) negative (!) linear acceleration the particles jitter (yellow particles in the MRP) - and sometimes go in a different directions too, in case of the MRP the yellow particles sometimes have some which goes down and not up as most of them. Jitter gets even worse if you do set a velocity to a non-zero value such as 1 for min + max. EDIT: Actually even if you have velocity set to a positive non-zero value the negative linear acceleration causes the particles to spasm as in the video.

Note: Green particles in the MRP have a non-zero velocity (positive) to show how it normally works.

You can see everything in the video below: https://github.com/user-attachments/assets/4d700e31-82a9-4b60-aeed-000c54efa02d

Steps to reproduce

Use GPUParticles3D, set gravity and animated velocity to 0, set linear acceleration to a positive value, set velocity direction in different direction and observe no changes. Do the above but this time set the linear acceleration to a negative value and observe the particles' jittered movement.

Minimal reproduction project (MRP)

LinearAccelerationTest.zip

viksl avatar Sep 28 '24 15:09 viksl

I would like to give this issue a try. I looked into it a bit yesterday and to me it seems that the issue is here: https://github.com/godotengine/godot/blob/1917bc3454e58fc56750b00e04aa25cb94d8d266/scene/resources/particle_process_material.cpp#L945

I am not sure though and dont want to step on anyones toes. If you want to fix this yourself i'll just look into another issue :D @QbieShay

Gurka2 avatar Oct 03 '24 06:10 Gurka2

@Gurka2 no problem! I self assigned to take a look, but if you already found the issue with the code, feel free to tackle it!

QbieShay avatar Oct 03 '24 13:10 QbieShay

It seems to me that the vec3 that is VELOCITY represents both initial speed with its length and the direction. If I am correct above we can solve this by either setting a float in the struct PhysicalParameters with the initial speed. Or we can document this and make this behaviour clear under the section for the particles.

I am not sure how I would implement this on my own. The main problem is i am not sure where the values in the shader come from. My solution would need to separate the initial value from the length of the vector VELOCITY. I wrote a message in the developer chat but got no response so figured I'll write it here aswell :D

Gurka2 avatar Oct 11 '24 07:10 Gurka2