Compute shaders for particle systems

Next on my list of new OpenGL functionality are compute shaders. They’ve been introduced into the GL core with 4.3, and pretty much allow you to do GPGPU directly in OpenGL without having to resolve to other APIs like OpenCL.

So my first compute shader demo implements a (simple) attraction based particle system. It generates two shader storage buffer objects (SSBOs). One for particle positions and one for particle velocities, and the compute shader then accesses these SSBOs to calculate particle velocities depending on an attraction point (in this demo it’s the mouse cursor) and accordingly updates the particle positions. So the whole particle system gets caclulated on the GPU, which should be a lot faster than doing it on a GPU.

Some screenshots, though they don’t do it any justice as the particle system is so dynamic and looks much better in motion :

You can grab the complete (Delphi) source from my bitbucket repository.

opengl