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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.