Sign in to follow this  
Jamiernmd

Particle System

Recommended Posts

Jamiernmd    122
Haven't used DirectX in a while so just trying to get back into it, so I decided to develop a simple particle system. The question I have is, is it quicker/more efficient to create a vertex buffer with a single quad in it, and loop the translation and rendering every time for each particle.... or Create a vertex buffer to contain all particles and render them all in one call to DrawPrimitive(). Obviously this will mean locking and unlocking the vertex buffer every frame to update the positions, velocities etc. So which is quicker, or is there perhaps a better way? Thanks

Share this post


Link to post
Share on other sites
MJP    19756
Rendering a bunch of triangles in one go will be much much faster than hundreds of DrawPrimitive calls. You should almost always aim to have as few calls to Direct3D functions, since they can result in an expensive switch from user-mode to kernel-mode so that the driver can take over. DrawPrimitive is especially expensive in this regard.

There are alternatives to locking a vertex buffer, however. For example you could shader constant instancing, or SM3.0 hardware instancing. See Humus's instancing demo for an example.

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