I've been looking at m$'s and Caleb's PointSprite examples, and I have a question concerning the implementation of the vertex buffer used to hold a chunk of points to be rendered as a PointList...

Caleb seems to have rather blindly followed m$'s implementation... There is a single vertexbuffer which is filled and drawn in "chunks", which lets us implement high particle counts with a smallish buffer.
Vertices are copied into the buffer one by one in a loop, then drawn in a chunk.

My question is as follows: assuming that the number of particles is limited by and cannot exceed the space available in the vertex buffer, is it not possible to keep the vertices in a vertexbuffer which we manipulate directly (locking and unlocking as appropriate) ??

I've already implemented LinkedList particles and particlesystems now, and I'm beginning to see it as duplication of resources !!
Could each ParticleSystem not own a smallish vertexbuffer of its own rather than a linkedlist of data elements which must be constantly shoved back into the rendering vertexbuffer? CreateParticleSystem could allocate a vertexbuffer just large enough for the pointlist for THAT particlesystem... the LinkedList objects for particles would still be needed, storing previous position, size, and the usual junk minus the current position field since its redundant now, making LinkedList objects 12 bytes smaller each, and eliminating the need to loop through the particles copying their vertex data during Rending...

Any thoughts?
Posted on 2002-12-16 22:22:17 by Homer
Afternoon, EvilHomer2k.

I'm under the impression that each particle in a particle system change over time (particularly their colour).

Usually, the texture used with them stays the same (the typical grey-scaled fading circle), and the diffuse colour of each particle is changed, so that we can have red/yellow particles for fire, or mid-grey/black particles for smoke, etc.

The size of the quad vertices for the particles are always the same (usually -1.0<->1.0).

The only real change would be the world matrix for each particle (updated over time with appropriate algorithm), as well as colour, plus a scaling factor (i.e. as smoke disipates(sp?), the scale of the particle increases in size).

So having a particle system with its own vertex buffer for the particles wouldn't be much use.

ummm...
hang on...

It *might* actually be useful after-all.
You'd still need a list of particles (to store the velocity info, etc).
However... it would mean modifying the particle systems' vertex buffer *every* frame (and also *every* particle system!)
You'd have to be updating each and every position vertice in the vertex buffer.

This would allow you to use only one world matrix for the particle system, and all particles would eject from it appropriately (i.e. blood pulsing out from a neck wound of a flopping body), but at the expense of having to update that vertex buffer.

Then, again...
You're *already* calculating this data using the normal method anyway. The only difference is that you'd be storing the data into the position vertice directly, and not as an individual particle matrice.

Running in software mode, I don't see a problem with your idea.
Running in hardware mode - big error.
The idea with hardware vertex processing, is that the particle vertex is on the vid card. All you do is chuck a different world matrix at it, and it'll render the object appropriately.

The only real way to test this, would be to create two proggys using both methods, and check the fps.

Cheers,
Scronty
Posted on 2002-12-18 18:29:17 by Scronty
Cheers for the feedback.
I'll be implementing both systems and will benchmark and let u know how it all went...
incidentally, just out of curiosity, what is it that you foresee as a potential problem in hardware processing of the vertexbuffer(s) ??
That is to say, what is the fundamental difference if I was to say, use, two vertexbuffers instead of one - and therefore, should I use N smallish buffers, what's wrong with that?
Are you implying that I should be using a single vertexbuffer for ALL vertex processing, including non particles?
As always, I value your opinion on these matters, you seem to have a better feel for m$'s stuff than I do - probably your C background :tongue:
Posted on 2002-12-22 05:44:45 by Homer