I missed shader programming when it was new. My first foray into 3d graphics was before 3D cards, and by the time the first programmable pipeline graphics cards became available, I was in the corporate software world writing, well, uninteresting non-gaming applications. Recently I’ve been re-writing Operation: Star Hammer to use 3D models, which as presented a lot of opportunities for some eye candy, and an opportunity to get my teeth into shader coding!
Something that 2D can’t do that 3D can is directional lights. I’ve added an effect to the game when the player fires their lasers that lights there ship, like a muzzle flash. Cool. But the shader effect I’m most pleased with to date is the afterburner effect, not necessarily from a visual standpoint, but from the power of using GPUs to do the work.
Players can get a temporary speed boost that uses energy. An afterburner flame is shown at the back of the players ship. To make this effect, I used a gas hotplate as inspiration. I grabbed a photo of my kitchen hotplates in action – domestic appliance and game development DO mix – to serve as a way to pick good colors and shape. The flame is model as a single mesh. The animation is done in the shader.

Something I noticed was that the real-world flame is mostly transparent in the centre, and almost opaque around the edges. So, in the pixel shader, I calculate the opacity based on the flame models normals.

Flames also flickers, which means only one thing…vertex animation. The vertex shader deforms the vertices of the model in interesting ways, giving a pretty decent illusion of flicker. Finally, I’m also animating the UV coordinates so that the texture appears to slide along the flame as well.
So, by combining a static model, and a static texture with a shader that does vertex animation, UV animation and some interesting alpha calculations, I’ve got an afterburner flame I’m pretty happy with.
Lessons learned : Use real-life objects to understand how things can/should look, GPU’s are awesomely useful, and it’s really fun to get the GPU to do all of the work.



Pingback: 2 weeks for DreamBuildPlay deadline « Black Lab Games Blog