Saturday, September 12, 2009

Every game needs motion blur

I’m not sure why, but for some reason or another I have this fascination with the motion blur effect used in video games. I’m not sure what it is that attracts my eye to this effect. A couple of days ago I decided that I would finally finish playing Shadow of the Colossus. One of the noticeable aspects of the game is its use of motion blur among many other special effects. Eventually getting inspiration from reading The Making of “Shadow of the Colossus” and just thinking about the use of motion blur in general, I figured I would try to implement it into my current project.
Now before I talk about adding the effect, I want to give a little background on my current project. The most basic description I can give about it is that it is a simple shmup. The game started out on the PSP and was intended to be a quick project. Pretty soon after it was started it was ported to the PC since debugging it on the PSP proved to be a pain. I may eventually port it back to the PSP when completed. The game mixes old and new ideas so it somewhat feels like an old 80’s arcade shooter with it’s wave based design, while making use of newer game play mechanics. One negative aspect of the project so far is that progress has been extremely slow. In what should have taken 3 to 4 months to complete has taken well over a year. To add to that the game is still far from finished. This has mostly been the result of me not working on it for months at a time and when I do get a chance to work on it, it is not for very long. However, I am not going to rush this game. I have taken a “I won’t release it till it’s finished” approach with it as opposed to the “Eh, whatever. It’s done enough” approach I took with the rush job that is Soldexus.
Now for implementing the effect in the game I wasn’t sure if it would work out. I had it worked out in my head how I would accomplish the effect but it was going to require alpha blending. Normally this would be a non-issue due to 3D acceleration, but I was using SDL’s blitter for rendering sprites and I figured alpha blending would be too expensive to justify using it so I never bothered with the effect until now. I did a small test to see if the effect was worth trying to implement and was pleased enough with the result to give it a try. The first thing that I had to do was write a function to apply motion blur to the background since that had been my intention for using the effect. As the game progresses the background scrolls faster and faster. The use of motion blur, I felt, would help convey the immense sense of speed that the player is traveling. After slapping together a function that would apply the effect I tested it out and I was somewhat right as the frame rate took somewhat of a hit. It was even worse when run in double resolution, but neither set up was “Oh shit” unplayable. Initially, background blurring came in 2 flavors, but was later adjusted so that it blurred more according to the speed it was scrolling.
And that was that. “Misshun comprete” right? All I had really wanted was for blurring to occur when the background sped up. Then you could say I got greedy, for lack of a better description. I started to wonder, “What if I add the effect to objects”? I started thinking about it throughout the day and how I would get it to work. I then came to a conclusion and that was “I want it”! However, adding the effect to objects would be a different beast altogether. Unlike the background, the movement of objects is more dynamic. It could change speeds at any time and could move at any angle while doing so. These had to be taken into account and handled accordingly. So I went to work on that and after a while I figured I had something that I might be able to use. I tested it out and was glad to see that it hadn’t turned out to be a horrible mess. It handled angles correctly most of the time and the intensity of the blurring differed depending on speed. It wasn’t perfect and didn’t take the camera into account when blurring, but it worked. So there it was, an effect I would never have thought of using, in my game. While not as pretty as it’s 3D counterpart, I can’t complain. Also, I like cheesecake.

Example