Closed OVOAOVO closed 8 months ago
What you tried to render particles is good. But to merge a engine feature, codes should be more generic.
The idea to create all particles as a big vertex buffer + index buffer is wrong. As you are using DrawInstance, you just need to take care about how many mininum primitive types are used. Then create vb/ib for primtive types prepared for instancing.
For this billboard branch just open the comment in ParticleRenderer.cpp Replace the original bx::mtxSRT and you'll see the normal billboard To run the shader's billboard just select the billboard in the inspector panel
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 :
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.
Use MeshUtils.hpp functions to replace duplicated vertex/index buffer build logics. Then should be OK to merge.
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. 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! 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. 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!
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). 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) In the Main.cpp file of EffkseerToCD you need to fill in the .efkefc file address This will give you access to the generated .cdbin 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
OurEngine
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).