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

Implement particle seek request and seed options. #92089

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

QbieShay
Copy link
Contributor

@QbieShay QbieShay commented May 18, 2024

2024-05-18.18-45-36.mp4

Works ONLY with GPUParticles3D for now.

Test project:
particles-skim-test.zip

This PR exposes the required API to then construct better particle timing tools on top of existing particles.
I implemented the seed control in this PR because otherwise any restart() would change the seed, which makes seeking impossible.

TODO

  • Implement request_process_time for CPUParticles
  • Implement rnadom seed for GPUParticles2D
  • Implement random seed for CPUParticles2D/3D

Closes godotengine/godot-proposals#6226
Simpler approach than godotengine/godot-proposals#7085 for editor purposes

@QbieShay QbieShay added this to the 4.4 milestone May 18, 2024
@AThousandShips AThousandShips changed the title Implemented particle seek request, get rid, and seed normalization Implement particle seek request, get rid, and seed normalization May 18, 2024
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected.

One strange thing I noticed though is that when you set particle seed mode to Random then restart particle emission, the seed is changed to a random value which you can see after changing it back to Custom. This makes sense, but this seed is always capped to 1 million due to the inspector hint:

image

See the second suggestion below which aims to address this.

PS: Are there any plans to expose a high-level GPUParticles3D property that allows for easy seeking, without needing a custom script? I assume this would need to force speed scale to be 0 though (like AnimationPlayer's Manual process mode).

if (fixed_fps > 0) {
frame_time = 1.0 / fixed_fps;
} else {
frame_time = 1.0 / 30.0;
Copy link
Member

@Calinou Calinou May 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd document this 30 FPS fallback for particles with fixed FPS set to 0 in the class reference in the fixed_fps description, as well as RenderingServer.particles_set_request_process_time().

Particle trails use the same 30 FPS fallback when Fixed FPS is set to 0.

@QbieShay
Copy link
Contributor Author

@Calinou yeah definitely I would like to get to something that has a slider to seek. I don't know yet what should be the design because I have a couple of ideas I want to explore. Those being:

  • maybe a vfx node, that encapsulates things for all particles.
  • maybe a particles track that does special things (seek) in editor
  • maybe a mix of the two?

There's also the issue that CPUParticles are not managed by the rendering server so i question whether the rendering server API is the correct way to go, or if i should keep that internal and only expose it via the node with the same interface for cpu and gpuparticles.

For now I'm stuck there but I haven't really dedicated more time to this yet.

@QbieShay
Copy link
Contributor Author

Oh and thank you for testing even in the incomplete state!!

@QbieShay
Copy link
Contributor Author

QbieShay commented May 20, 2024

One strange thing I noticed though is that when you set particle seed mode to Random then restart particle emission, the seed is changed to a random value which you can see after changing it back to Custom. This makes sense, but this seed is always capped to 1 million due to the inspector hint:

I noticed that as well, and I am not sure why it resets even if the seed is set manually. For what i thought i wrote in the code, it should be possible to override the seed, but it doesn't seem to be working.

@QbieShay
Copy link
Contributor Author

add pre process on clear

@QbieShay QbieShay force-pushed the qbe/particle_seek branch 4 times, most recently from afb2e01 to 8a086b6 Compare June 7, 2024 07:46
@Calinou
Copy link
Member

Calinou commented Jun 7, 2024

I tested the latest revision of this PR. I've gotten GPUParticles3D seeking to work successfully (it's quite simple to script, only 2 lines of code):

$GPUParticles3D.restart()
$GPUParticles3D.request_particles_process(value)

Testing project: test_pr_92089.zip

particle_seeking.mp4

Some remarks:

  • What's the difference between request_particles_process() and request_process_time()? For GPUParticles3D seeking, it seems I can call either of them (or both) and get the same result visually.

  • I noticed that when CPUParticles3D have their Speed Scale set to 0.0, seeking will not make any particles emit (unlike GPUParticles3D where particles are visible as expected).

  • I get some errors when opening the editor or running a project:

ERROR: Class GPUParticles3D already has a method set_seed_mode.
   at: bind_methodfi (./core/object/class_db.cpp:1793)
ERROR: Class GPUParticles3D already has a method set_seed.
   at: bind_methodfi (./core/object/class_db.cpp:1793)
  • This PR makes CPUParticles3D simulate much faster than intended (compared to master or GPUParticles3D in this PR). The speed depends on the rendered FPS (not particle fixed FPS) – at 10 FPS, speed is mostly equivalent to GPUParticles3D, but still a bit faster.

@QbieShay
Copy link
Contributor Author

QbieShay commented Jun 8, 2024

Thank you @Calinou !

What's the difference between request_particles_process() and request_process_time()? For GPUParticles3D seeking, it seems I can call either of them (or both) and get the same result visually.

Most likely copy-paste error >< i renamed things but I didn't change the little notepad i use to port codeblocks

I noticed that when CPUParticles3D have their Speed Scale set to 0.0, seeking will not make any particles emit (unlike GPUParticles3D where particles are visible as expected).

I had to change something to make it work for gpuparticles, but i didnt for cpuparticles. I need to fix that too, thanks!

I get some errors when opening the editor or running a project:

Not sure what that is, will investigate.

This PR makes CPUParticles3D simulate much faster than intended (compared to master or GPUParticles3D in this PR). The speed depends on the rendered FPS (not particle fixed FPS) – at 10 FPS, speed is mostly equivalent to GPUParticles3D, but still a bit faster.

Likewise, will investigate.

@QbieShay QbieShay force-pushed the qbe/particle_seek branch 2 times, most recently from 741b5fd to a8ccf34 Compare June 9, 2024 14:56
@QbieShay QbieShay force-pushed the qbe/particle_seek branch 2 times, most recently from 38c2599 to f78e8ad Compare June 18, 2024 20:24
@QbieShay QbieShay force-pushed the qbe/particle_seek branch from f78e8ad to 49c21ca Compare June 27, 2024 10:37
@QbieShay QbieShay force-pushed the qbe/particle_seek branch 2 times, most recently from b6eb5df to a51b2d4 Compare July 14, 2024 13:43
@QbieShay QbieShay force-pushed the qbe/particle_seek branch from a51b2d4 to fc1337c Compare August 8, 2024 09:20
@QbieShay QbieShay changed the title Implement particle seek request, get rid, and seed normalization Implement particle seek request, ~~get rid~~, and seed normalization Aug 8, 2024
@QbieShay
Copy link
Contributor Author

QbieShay commented Aug 8, 2024

Update:

Removed get rid in case we want to manage separate bursts as under-the-hod separate renderingserver particles.

Exposed process request on all nodes

Documented relevant nodes.

Many thanks to @Calinou @AThousandShips and Tuppy

@QbieShay QbieShay marked this pull request as ready for review August 8, 2024 09:23
@QbieShay QbieShay requested a review from a team as a code owner August 8, 2024 09:23
@QbieShay QbieShay requested a review from a team as a code owner January 8, 2025 22:23
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akien-mga akien-mga requested review from paddy-exe and a team January 9, 2025 12:10
@QbieShay QbieShay force-pushed the qbe/particle_seek branch 2 times, most recently from aafdd02 to c40d295 Compare January 9, 2025 18:03
The purpose of this code is to expose the necessary
functions for users and engine devs to develop tooling
for properly timing and seeking inside particles.

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Copy link
Contributor

@paddy-exe paddy-exe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. Have only tested with Calinou's test project and works fine for me as well. Amazing work on this Qbie!

@akien-mga akien-mga merged commit 133db1f into godotengine:master Jan 13, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

QbieShay added a commit to QbieShay/godot that referenced this pull request Jan 21, 2025
Splizard pushed a commit to grow-graphics/godot that referenced this pull request Feb 2, 2025
tGautot pushed a commit to tGautot/godot that referenced this pull request Feb 5, 2025
tGautot pushed a commit to tGautot/godot that referenced this pull request Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow optional seed specifying for particles
6 participants