Stateless particle systems?

Blitz3D Forums/Blitz3D Programming/Stateless particle systems?

"To simulate particles on a GPU you can use stateless or state-preserving PS. Stateless PS require a particle's data to be computed from its birth to its death by a closed form function which is defined by a set of start values and the current time."


In other words, the article is saying that you can render particles using a pixel shader, with, presumably, one particle per pixel, and using equations like the following:

Current_X# = Start_X# + Normal_X#*Current_Time#
Current_Y# = Start_Y# + Normal_Y#*Current_Time#

Note that Start_X# and Start_Y# need not be stored if all particles start at the same location, or you have a randomize function where you can seed it so the output is the same every time. Same goes for Normal_X# and Normal_Y#. The only variable is time, and the current location is not stored to be used in the equation again later, it is only used that frame to draw the particle.

This is the equation for a line. To be useful you'd need more complicated equations which define curves, and allow for acceleration and deceleration.

With this method it is not possible for particles to collide with anything and change direction, but it is possible to have complex looking motion and lots and lots of particles.


[edit]
My bad, I should have read the article all the way through...

While what I described would work, the article goes on to describe a method which uses textures to store data.

My first guess as to what it was doing... I was going to say it's like a water simulation somehow.

There is a well known algorithm for simulating water where all you do is update a bitmap each frame using it's last set of values and waves move through it automatically when changes are made to it.

This works because the height of a water pixel also encodes it's energy. Ie, a tall wave has a lot of energy and will collapase when when it does will send out other waves in all directions.

Skimming through this algorithm appears to use a texture to store velocities and positions, but upon closer inspection, it does not appear ro be doing anything like the water algorithm. In fact, it appears to be anyhting BUT "stateless". It appears to just use the textures to store the locations and velocities of each particle, and then it calculates it's motion from that in a pixel shader. Then it draws the particles using a vertex shader.

I guess the advantage here is the GPU is doing all the work, rather than the CPU.

This sort of thing won't help anyone write a faster particle system in Blitz because it doesn't have pixel or vertex shaders.
[/edit]