How it works...

There's quite a bit here to sort through. Let's start with the vertex shader.

The vertex shader is broken up into two primary functions (update and render). The update function is used during the first pass, and uses Euler's method to update the position and velocity of the particle. The render function is used during the second pass. It computes the transparency based on the age of the particle and sends the position and transparency along to the fragment shader.

The vertex shader has three output variables that are used during the first pass: Position, Velocity, and Age. They are used to write to the feedback buffers. 

The update function updates the particle position and velocity using Euler's method unless the particle ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.