Sign in to follow this  
martinperry

Particle engine - efficiency

Recommended Posts

martinperry    102
Hi, i have little question. I am currently building particle engine, that can handle multiple particle emitors. I have question about effiency. Should I create for each particle system one effect, or should I rather use one global effect for all systems and set-up system settings in runtime (eg. send to shader in every frame gravity, wind, texture etc.) I mean it this:
struct ParticleSystem 
{
 public Particles[] particles;
 public VertexBuffer vb;
 public Matrix worldMatrix;
 public Settings systemSettings;
 public Effect fx;  //<-------------- use it this way ? or without it and have it global for all effects
}
And second question is about VertexBuffer. So far, I have 1 vertex buffer for each system. I personally think, that its better, then have one huge VertexBuffer for all systems together, beceause some of the systems can be updated only on GPU (no need of Dynamic VB), some need to be updated on CPU (because of collisions). And second of all, systems are added and removed in realtime. Is it good solution, or should i build it another way ? Engine Pseudo-Code
List of systems

AddSystem()
{
 init particles
 init VB and fill it with particles
 add system to List
}

RemoveSystem()
{
dispose VB, Texture
}

RenderAllSystem()
{
foreach iterate through all systems and render them // here are multiple VB not quite good solution
}

RenderSystem() //render one particular system - multiple VB are quite good for this
{
 set-up shader params like gravity, wind, view, projection etc. // need to set it up in every frame. Is better use one shader for each system, or one global and set things over and over again

render system

}

Thanks for your advice

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this