For the last couple years I have been interested in the use of Perlin noise and OpenGL additive blending to create soft organic atmospheric effects that can add some really nice subtle character to a piece. While I’m still not quite there yet, I have made some headway recently in identifying the underlying systems going on with this effect. As indicated in the title there are two key components to creating this effect: a particle system and OpenGL (specifically additive blending). This isn’t a tutorial, so I’m not going to go very far explaining the code behind these effects, just document the concepts I’ve learned.
The thing that took the longest for me to figure out is the use of a particle system for this effect. Although the perceived shapes on the screen are indeterminate and hazy, what is actually going on is that there are a couple (usually not very many) quite large texture-mapped OpenGL quads (mapped with a texture like this one or one randomly generated at runtime using Perlin noise). Animate these quads as if they were particles using the physics of your choice (slow rotations, orbiting, magnetism / gravitation equations, etc)
Once you’ve created some fairly large particles and assigned texture-mapped OpenGL quads to the locations of these particles you can use some really fun OpenGL magic to get the lighting and haze effects we’re after. This topic is huge and, quite frankly, scary, so I’m just going to quickly outline the steps needed to create the necessary blending
- Enable GL_BLEND in OpenGL
- Disable GL_DEPTH_TEST
- Change the blending function to the following:
glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE );
Pitfalls and problem areas
But then I hit a snag and stopped working on it. I used Java (Processing) to create the following program and began suffering from severe (read debilitating) lag issues, which I attribute to Java being, well, a piece of crap. But more likely my lag issues are from my inexperience with texture mapping quads using JOGL’s OpenGL bindings. I load Textures into my emitter class, then load TexCoords objects based on the active Texture into my particle class. The program then pops out about 10-20 particles from the emitter each time I click the mouse. Depending on the texture in use it can only take a couple of mouse clicks before my program’s framerate drops below 20fps and becomes unresponsive. If you have any insights on this issue, please leave a comment!
Using Processing (+ eclipse) and OpenGL alpha blending to simulate smoke or explosive effects. Ultimately I would like to make this audio-reactive a la Flight404’s old Solar videos.
Each ‘explosion’ is about 30 good sized particles with a Perlin noise texture mapped to them and alpha blended / shaded to create nice interactions.