Jump to content
  • Advertisement
Sign in to follow this  
deadlydog

Particle System/Vertex Buffer Questions

This topic is 3827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm making a 3D point sprite particle system in C# and XNA. I have been looking at the ParticleSystem3D Sample they give you on the XNA Creators Club website to see how their particle system was done. They did their particle system on the GPU, while I want to do mine on the CPU (as I need to perform dynamic operations which cannot be done in HLSL). So I have a couple questions: 1 - My particles are going to have a lot of properties that affect its movement (velocity, acceleration, temperature, mass, etc). I was going to store all of this information in a CParticle class, create an array of CParticles which I operate on and update, then copy the array to a DynamicVertexBuffer each frame to draw the Particles. It seems very inefficient though to copy the whole array into a VertexBuffer every frame. Is it possible to just use the VertexBuffer to hold my Particles and to operate on them from there (without using HLSL)? or is there some better way to do it? 2 - The VertexBuffer really only needs 4 pieces of information to draw the point sprite; position, normal, color, and texture coordinates. Would it make more sense to only copy these values into the VertexBuffer, since all of the other properties will be modified on the CPU (not the GPU)? Any comments/suggestions would be appreciated. Thanks. [Edited by - deadlydog on June 18, 2008 9:51:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
In regards to question 2, would it make sense to keep the vertex's position, normal, color, and texture coordinates in a separate structure than the rest of the CParticle data? Sorry, I'm new to using the Vertex Buffers and I'm not quite sure how to go about accomplishing what I want to do. Any help is appreciated. Thanks.

Share this post


Link to post
Share on other sites
In my experience #1 really depends on how many particles you expect to be updating every frame. A good particle effect should look good while at the same time having as few particles as possible. The best idea would be to just get it working first even if it 'seems' inefficient at the time and then see what you can do from there if it actually is a problem.

Optimisations can certainly be made:
By the looks of things you were perhaps thinking of using 4 streams? Use 3 and pack the tex coords into the w component of the position and normal.
Do you really need the normal stream? Are you going to be lighting your particles? Infact you should probably look at whether you really need the colour and tex coord streams too...are these going to change on per particle basis? This may change on a per effect basis so its worth thinking about what kind of effects you want to create.

Share this post


Link to post
Share on other sites
So before particle systems started being done on the GPU, were they done how I describe in question 1? That is, was the vertex buffer overwritten every frame? and if so, I assume it's much more efficient to just copy the vertex data over into the vertex buffer, instead of the whole CParticle class, as it would require less memory and take less time to copy over, right? Thanks.

Share this post


Link to post
Share on other sites
Depending on how many particles your dealing with, updating vertex buffers every frame isn't a problem. Dilute to taste :)
And yes you only copy over what you need in the shader - Position at the very least.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!