Sunday 20 January 2013

Shaders for the Future

Here is a gameplay screenshot of A Case of the Mondays:


Now where is the main character? He's hidden behind that darn mysterious object. We need to implement some kind of "x-ray vision" so that the character is always visible to the player. Something like this:

In the image above, the object that is blocking the player from being seen is made transparent so we can see our little trouble maker. This second image was created in Photoshop, but how can we implement something like this in game? My original thought was to cast a ray from the player's position to the camera's position, loop through each object in the game and test for collision with the ray, if the ray hits an object, make the object transparent. If you know of a better way to do this with a shader and feel like offering a suggestion, tweet me at @MikeGameDev or leave a comment below.

Here is the same screenshot again but with shadows.


You can't have lighting without shadows, it just doesn't look right. Even Super Mario 64 had some shadows, granted it was just a circle of darkness below Mario but even in this primitive form we knew what it was. The original plan for our game's shadows was to just have simple hard shadows but after viewing the #i2350 homework questions, it looks like we are going to have soft shadows and maybe a stencil buffer.

Here is a similar screenshot to the ones above but this time instead of a single boring grey per vertex light source, we two slightly more interesting per fragment light sources.

With the addition of just two light sources (note the two specular highlights on the mysterious object, one from each light source) the game transforms from dull and grey to red and exciting. But it still looks a little bland...
The above shot is with the addition of HDR, now things that are dark are darker and things that are light are lighter. Bump mapping would sure look nice in the above image but I don't feel like getting into code mode...yet.

The above images are just some of the effects we plan on implementing in our game this semester. As mentioned, adding just two light sources made the game look significantly better now imagine what it would look like with 50 light sources, I also plan on implementing deferred shading into the game.

On a side note, if you ever wondered why we named the game "A Case of the Mondays" its a reference from the movie Office Space. It was the night before the game was due and we didn't have a title so we figured why not.