How it works...

Recall that the first two input attributes to the vertex shader are not-instanced, meaning that they are advanced every vertex (and repeated every instance). The last four (attributes 3-6) are instanced attributes and only update every instance. Therefore, the effect is that all vertices of an instance of the mesh are transformed by the same matrix, ensuring that it acts as a single 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.