Mixing the Particles with Additive Blending

When we do different effects in OpenGL, we often have to think back to the effect that we’re trying to reproduce. If we imagine our three particle streams as a fireworks fountain, like the one we’d see at a fireworks show, then we’d expect the particles to give off light; and the more of them there are, the brighter things should be. One of the ways that we can reproduce this effect is by using additive blending.

Let’s enable blending by adding the following code to ParticlesRenderer in the onSurfaceCreated method:

Particles/src/com/particles/android/ParticlesRenderer.java
 
glEnable(GL_BLEND);
 
glBlendFunc(GL_ONE, GL_ONE);

That’s it! First we enable blending, and then we set the blending mode to additive ...

Get OpenGL ES 2 for Android 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.