godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 68 forks source link

Add a signal to GPUParticles3D collision #10048

Open eddieataberk opened 4 days ago

eddieataberk commented 4 days ago

Describe the project you are working on

A game utilizes particle effects.

Describe the problem or limitation you are having in your project

In Unreal Engine we were using Particle Collision effects to spawn sound, decals, and other particle collision effects. While Godot can use collision events to spawn other particles by assigning them as Sub Emitters there are no ways to retrieve collision data from script. The existing finished() signal doesn't trigger even if particles are set to hide on collision.

image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a contact_monitor property to particles and add a collided() signal with a signature that contains location and normal etc.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

N/A

Is there a reason why this should be core and not an add-on in the asset library?

This is about the core particle system.

Calinou commented 4 days ago

This is technically impossible because GPU particles are simulated purely on the GPU. The CPU is never aware of their position at any point in time, so there is no way to know that collision happened. Doing this would require stalling the pipeline every frame, which would negate any performance benefit from using GPUParticles as opposed to CPUParticles.

eddieataberk commented 4 days ago

Can we have collisions or Collision events in CPU particles?

Calinou commented 4 days ago

Can we have collisions or Collision events in CPU particles?

As mentioned in the linked proposal, that's feasible. However, CPU particles are currently considered to be in maintenance mode as they've proven to cause maintenance burden. There is discussion on unifying CPU particles and GPU particles together so that CPU particles are easier to keep in sync relative to GPU particles.

This is the reason why CPU particles haven't gotten the updated inspector organization that GPU particles got in 4.2, or particle turbulence.