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

Inherit initial velocity from moving emitters #64

Open
malleusinferni opened this issue Oct 14, 2022 · 2 comments
Open

Inherit initial velocity from moving emitters #64

malleusinferni opened this issue Oct 14, 2022 · 2 comments
Labels
C - enhancement New feature or request

Comments

@malleusinferni
Copy link

Particles currently have an initial velocity determined by the InitModifiers on an EffectAsset and the GlobalTransform of the emitter entity. Certain classes of visual effects also need to account for the velocity of a moving emitter, and add this value to the initial velocity of all its spawned particles.

To maintain open-ended interoperability with physics engines, the API for this feature could expose an initial velocity field on the ParticleEffect component, and make the API consumer responsible for copying the appropriate value from any physics components.

@djeedai djeedai added the C - enhancement New feature or request label Oct 14, 2022
@djeedai
Copy link
Owner

djeedai commented Oct 14, 2022

I think the way I'd like to handle that is that we calculate the emitter's velocity, defined as the delta position between 2 frames of the GlobalTransform::position of the emitter divided by the frame delta time. And then we pass that emitter velocity to the GPU alongside the spawn count for each frame, and the compute shader adds it to the particle's own velocity. That's reasonably straightforward.

Note that we're assuming here a world-space simulation. But that's the only mode available today so that's fine.

@malleusinferni
Copy link
Author

The previous and current GlobalTransform may need to be compared regardless for the purposes of #65, so deducing velocity that way makes plenty of sense, as does interpolating it between frames. In that case, the user-facing API for this feature should expose other ways to manipulate the emitter's calculated velocity before adding it to the velocity of each particle — for example, a scaling factor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants