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

Add "Hide on Contact" collision mode to ParticlesMaterial #61238

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented May 20, 2022

This can be used to make particles disappear when colliding, rather than bouncing around or sticking to surfaces.

This is useful for rain particles which should not be able to go through floors/ceilings, but shouldn't stick to surfaces either.

Performance-wise, this will perform better than using Rigid since inactive particles are no longer rendered – their vertices are culled by the GPU, and the mesh materials won't use up any fillrate.

This implementation works with subemitters. You can use a "parent" particle that has collision mode set to Hide On Contact, and a subemitter with Rigid collision mode. If you use similar-looking particles, this can be used to simulate scaling or color changes on contact. This can also be used to create decal billboards on contact (using small plane meshes, not actual Decal nodes).

simplescreenrecorder-2022-05-21_00.10.39.mp4

This implementation currently doesn't handle trails correctly (they will create a "streak" back to the particle system origin), but I believe this is an engine bug.

Testing project: https://0x0.st/oajR.zip (link expires in April 2023)

@Calinou Calinou added this to the 4.0 milestone May 20, 2022
@Calinou Calinou force-pushed the particlesmaterial-add-fade-on-contact-collision-mode branch 2 times, most recently from d7b7366 to e0c754f Compare May 20, 2022 22:21
@Calinou Calinou requested a review from a team as a code owner May 20, 2022 22:21
@Calinou Calinou changed the title Add "Fade on Contact" collision mode to ParticlesMaterial Add "Hide on Contact" collision mode to ParticlesMaterial May 20, 2022
@Calinou Calinou force-pushed the particlesmaterial-add-fade-on-contact-collision-mode branch from e0c754f to 27128da Compare May 20, 2022 23:01
This can be used to make particles disappear when colliding, rather
than bouncing around or sticking to surfaces.

This is useful for rain particles which should not be able to go
through floors/ceilings, but shouldn't stick to surfaces either.
@Calinou Calinou force-pushed the particlesmaterial-add-fade-on-contact-collision-mode branch from 27128da to 17ad6df Compare August 19, 2022 20:32
@Calinou
Copy link
Member Author

Calinou commented Aug 19, 2022

Rebased and tested again, it works as expected.

@clayjohn clayjohn requested a review from QbieShay August 19, 2022 20:59
@clayjohn
Copy link
Member

Looks good to me, would be useful to hear from @QbieShay as well

@akien-mga akien-mga merged commit 56752e3 into godotengine:master Aug 24, 2022
@akien-mga
Copy link
Member

Thanks!

akien-mga added a commit that referenced this pull request Aug 24, 2022
@Calinou Calinou deleted the particlesmaterial-add-fade-on-contact-collision-mode branch August 24, 2022 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants