godotengine / godot

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

`GPUParticlesCollisionBox3D` and `GPUParticlesCollisionHeightField3D` produce different results in the same setup #93570

Open derkork opened 3 weeks ago

derkork commented 3 weeks ago

Tested versions

v4.2.2.stable.mono.official [15073afe3]

System information

Godot v4.2.2.stable.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4080 (NVIDIA; 32.0.15.5599) - AMD Ryzen 9 7950X3D 16-Core Processor (32 Threads)

Issue description

I have set up two identical particle systems. Both spawn cubes and have collision enabled and set to rigid. Under both particle systems I have a CSG cube representing a surface. The left cube has an GPUParticlesCollisionBox3D enclosing the cube, the right one has a GPUParticlesCollisionHeightField3D looking at the cube. The height field works very nicely, while the collision box "leaks" particles. I would expect both setups to behave the same way (ideally like the height field).

https://github.com/godotengine/godot/assets/327257/a1414ae7-645d-4f45-be4d-3db0f08d2bbc

Steps to reproduce

Open particle_collisions_test_2.tscn in the attached reproducer project. There you can see the setup from the video and play with it.

Minimal reproduction project (MRP)

reproducer2.zip

smix8 commented 3 weeks ago

Just normal tunneling problems because your geometry and bake box is just too thin for your velocity and the precision possible with a baked texture, which is what both nodes use for the particle collision.

The heighmap only works because you set the bake box to 50 units. If you shrink it to 0.5 like the other collision you get similar tunneling artifacts below the visible geometry on both but no leakage. The height map makes the particles sink less into the geometry but that is expected as it is its entire job and reason why it is a specialized node. If you increase the thickness of both you get no issue on both except that particles on the collision box sink a little more into the ground.

derkork commented 3 weeks ago

I increased the thickness of the box and this indeed fixed the problem. But then again we're not talking excessively crazy speeds here. These particles are falling with default gravity from a height of 4 meters, which is about 8m/s. Is there a suggested way to deal with this if you don't want to have walls that are multiple meters thick to block things like raindrops?

Calinou commented 3 weeks ago

Is there a suggested way to deal with this if you don't want to have walls that are multiple meters thick to block things like raindrops?

Yes, set Fixed FPS to 0 on the GPUParticles3D node so it's simulated every rendered frame instead of a fixed 30 FPS. You can also set it to a fixed value that is higher than the default, which may lead to more predictable behavior.