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

ParticleSystem #415

Merged
merged 91 commits into from
Mar 4, 2024
Merged

ParticleSystem #415

merged 91 commits into from
Mar 4, 2024

Conversation

OVOAOVO
Copy link
Contributor

@OVOAOVO OVOAOVO commented Nov 3, 2023

Workflow

If you want to use the particle system directly, including importing resources, you can add a particle emitter or a particle force field by clicking on the + in the EnitityList on the left.
image
Through the right side of the inspector panel to adjust the corresponding parameters, but at present our particleType only Sprite can be used, as well as the instance State at present because the uber shader has not yet been perfected the effect is not correct, these two points please note that!
image
Currently there is only one rotational force used in the force field, after checking the RotationForceValue box, a centripetal force will be generated inside the blue box.
image
If you need to import, please produce a .efkefc file (this file is generated by EffekSeer export) and export it to .cdbin file in AssetPipline, then directly drag it to the engine scene, we will access EffekSeer to make the process of importing less cumbersome!
image
image

These are two files you can check out https://github.com/CatDogEngine/TestAssets/tree/main/Particle
You can see the introduction of these two documents in

To generate a cdbin file first you need to compile the EffekSeer related .exe .dll in AssetPipline (please add the EffekSeer SDK to your OS environment variables, then use MakeThirdParty.bat to build AssetPipline).
image
image
Fill in the EffkseerToCD command parameters with the directory you want to output to and the filename.(the first parameter is empty fill in some random but can not not fill, the second parameter that is the output of the directory and file name)
image
In the Main.cpp file of EffkseerToCD you need to fill in the .efkefc file address
image
This will give you access to the generated .cdbin
image
Currently .cdbin import only supports properties that can be adjusted inside the engine, you can create a new particle emitter component to see which properties can be imported into the engine.

Functions completed so far and their drawbacks

Basic state update of particles (Particle.h/cpp, ParticleRenderer.h/cpp )
Particle pool maintenance (ParticlePool.h/cpp)
GPU particles (vs/fs_particle.sc)
Instantiating particles (ParticleRenderer.h/cpp, vs/fs_particle.sc)
ECS component for particles (ParticleComponent.h/.cpp)
Billboard View particles (ParticleRenderer.h/cpp, vs/fs_wo_billboardparticle.sc)
Particle shader variants (ParticleComponent.h/cpp, vs/fs_particle.sc)
Particle Force Field(ParticleForceField.h/cpp)

So far our particle base is relatively perfect, I mean the maintenance of particle pool and ECS management, but there are some features are not yet perfect, such as shader variants now do not support .vs caused by some of the functionality of the anomalies, we will follow up to fix these.
Secondly, there are some features that we will do in the future, for example, the current particle type only supports mesh but not Ribbon Track and model in the list, we will support these features in the future, the shape of the particle emitter is only a box at the moment, we will add hemisphere, sphere and so on after that, there is no depth sort at the moment, which causes the particles to block each other, we will add bipartite sort or subsumption sort in the future. Translucent and opaque rendering, particle self-illumination, multi-threading .... etc. etc.
There are still a lot of things that need to be done

Some Example

EffkSeer

EffekSeer

OurEngine
catdog1
catdog2
cadog4
catdog3

Some performance

In the case of using instantiation the maximum number of particles that can be supported in the current engine is around 20,000 (maintained at 60fps VGA: 6600X).

@OVOAOVO OVOAOVO requested a review from roeas November 3, 2023 16:24
@T-rvw T-rvw removed the WIP Work In Progress label Feb 24, 2024
@T-rvw
Copy link
Contributor

T-rvw commented Feb 28, 2024

If you are ready to merge, please resolve conflicts and add some introduction to what particle system in this PR looks like because it is not a small feature which you can learn about it in 5 mins.
As a suggestion, you should comment :

  1. Introduce a workflow from prepare asset file to render and adjust parameters to non-developers. Attach picture/gif is better.
  2. Introduce your feature list, implementation's pros and cons ri developers. Reference documents or codes.

@OVOAOVO OVOAOVO requested a review from T-rvw February 29, 2024 05:30
@T-rvw
Copy link
Contributor

T-rvw commented Feb 29, 2024

You can also show some examples in this PR :
snapshot in Effekseer editor, snapshot in CatDogEditor.
How to adjust parameters to get a sprite particle emitter which has good visual appearance.

////const cd::VertexFormat *requriredVertexFormat = emitter.GetVertexFormat();
////particleEmitterComponent.SetRequiredVertexFormat(requriredVertexFormat);
////particleEmitterComponent.GetParticleSystem().Init();
if (nameof::nameof_enum(emitter.GetType()) == "Sprite") { particleEmitterComponent.SetEmitterParticleType(engine::ParticleType::Sprite); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use cd::ParticleType is better because they are all same:
particleEmitterComponent.SetEmitterParticleType(emitter.GetType());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it's not.
cd::ParticleEmitterTypeTraits::Type not suit engine::particleType

Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp Outdated Show resolved Hide resolved
Engine/Source/Editor/EditorApp.cpp Outdated Show resolved Hide resolved
Engine/Source/Editor/UILayers/AssetBrowser.cpp Outdated Show resolved Hide resolved
Engine/Source/Runtime/ECWorld/ParticleEmitterComponent.h Outdated Show resolved Hide resolved
Engine/Source/Runtime/ECWorld/ParticleEmitterComponent.h Outdated Show resolved Hide resolved
@T-rvw
Copy link
Contributor

T-rvw commented Mar 3, 2024

Use MeshUtils.hpp functions to replace duplicated vertex/index buffer build logics.
Then should be OK to merge.

@T-rvw T-rvw merged commit 370d5a6 into main Mar 4, 2024
2 checks passed
@T-rvw T-rvw deleted the particle_and_nodeTest branch March 4, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants