Particle simulation

General Purpose GPU computing is using the GPU to solve a problem that is not graphics. We will look at particle simulation. This is done storing the particle data on the GPU and using shaders to read and update the data. We are going to do this using textures, framebuffers, and shaders. In general, OpenGL supports these kind of computations with a "Transform Feedback" pipeline. Since we are using OpenGL, there are still limitations related to its focus on graphics. The parallel compute language OpenCL can be used when more flexibility is needed.

We can store particle position and velocity in textures. We can the textures as input to the shaders. The shaders can then read the current particle position and velocity. The shaders will then need to compute the new positions and velocities and write the output. The new values are output to the framebuffer. So, the framebuffer must be setup to have two color buffers, one for position and one for velocity. Given these requirements, setup:

A shader reads the input textures, then outputs the new values to the output buffers. Then, the source and destination buffers are switched for the next update cycle.


Your repository should have the Particles project.