Tuesday, January 25, 2011

First Investigation Team: Intruder

Finally, I have finished developed another game by using XNA!

Basically it is a 2D real-time strategy game. All you need to do is conquer/eliminate your enemy bases.

This is my first time to develop a game with AI. The AI that's I've included is Decision Making + Finite State Machines. Although the AI is still not smart enough but hope that in future if I have free time I will try to improve it :)

Again, since I'm not an artist, so what I did was using google to find images and edit in Adobe Photoshop. Hope that you won't mind about it.

Enough of talk, here are some screenshots:
*Main menu screenshot

*In game screenshot 1

*In game screenshot 2

*Pause screeen

Video demo:




Download link here:


PS: You need to have XNA Runtime Redistributable 4.0 and .NET Framework 4.0 installed before you can run this game.

Tuesday, January 11, 2011

Shader - Normal Mapping

Normal mapping. I guess this is one of the important technique in game development. It can gives u a high details of an model without the need of high poly model. Sounds cool isn't it? Anyway, Computer graphics always cool!

Before you can do a good normal mapping, you need to have a good normal map. Question.... how do I create normal map? Easy! Model a really high poly and detailed model, and generate normal map from it first (I believe most 3D software did provide the function of generating normal map) After you have generated the normal map, reduce your poly count until it fits your game :)

The concept behind normal mapping is, do the lighting calculation at Tangent Space aka Texture Coordinate Space. I don't think my explanation will be good. If you wish to know more about this, try to look at this page or this page.

In short, you need to find out TBN matrix and convert your lighting direction to the tangent space by multiplying with the TBN matrix.

TBN matrix is (Tangent, Binormal, Normal) matrix.


Here are some screenshots:
*Original model without applying normal mapping

*Same model after applying normal mapping



Key Control:
1: Without applying normal mapping
2: Applying normal mapping

Shader - Toon Shading

Toon shading! Sounds interesting isn't it?

Well, basically toon shading is another simple technique which you can be easily done in shader. (I mean a basic toon shading. If you want to do advanced toon shading, of cause it is difficult)

Since mostly toon shading gives you an unrealistic lighting. Basically it just has about 3 or 4 bands of lighting. So what you need to do is clamping the lighting value based on the look-up table.

What is the look-up table? Well, it just store the pre-defined value which you are going to use for the lighting clamping. Which mean, if your look-up table has only 3 values. You final result of the whole model (lighting) will only have 3 values as well.

For example:
The lighting value for that particular pixel is 0.4f, by using look-up table:

if (light > 0.8f)
light = 1.3f;
else if (light > 0.5)
light = 0.9f;
else
light = 0.5f;

From the pseudocode above, you can see that, no matter what value you get from the calculation, it will convert to either one of the 3 pre-defined values.

Here are some screenshots:
*Original model

*After applying toon shading (You can see that there are only 3 intensity level of light on the model)

*Toon shading with outline


If you wish to know more about toon shading, you can wiki it.



Key control:
1: Default model
2: Toon shading
3: Toon shading with black outline
4: Change the background color to white/black

Shader - Per-Pixel Lighting

Actually I just started to learn shader about 1 month. Finally I have something to show :)

First I would like to show is per-pixel lighting which I've done by myself after reading The Cg Tutorial. It is an awesome book and recommended to all beginners in shader programming.

Per-pixel lighting is simple, basically it is like per-vertex lighting but instead of putting all the codes in vertex shader, u put it in pixel shader. Well, in order to optimize the code, remember do all the position calculation in vertex shader first and only pass them to the pixel shader so that pixel shader don't need to do so many works.
Simple ey?

The only thing you need to know is, the theory of lighting in computer graphics!

Basically the equation of lighting is:
lighting = emissive + ambient + diffuse + specular
(Actually the emissive term doesn't seems like really important)

The formula above is the most basic lighting formula. Of cause there are more like adding attenuation. I haven't try that personally so I'm not going to talk more about that yet.

Enough of talking, here are some screenshots:
*Ambient light only

*Diffuse light only

*Specular light only

*Ambient + Diffuse + Specular (Facing the light)

*Ambient + Diffuse + Specular (Doesn't facing the light)

Video Demo:




Key control:
1: All lighting added together
2: Ambient light only
3: Diffuse light only
4: Specular light only

Wednesday, January 5, 2011

Version Control

Last time some of my friends did ask about me how do all the source files being combined into a project? How do different programmers can separate their tasks and work on it?

So here I just try to give a brief idea about it.
Basically last time I have some experience in using version control during internship in GameINC.

First of all, you need to come out your project architecture, after the architecture out, then the engine programmers should start and build the base code before the team working on the gameplay.

After the base code, it's time for version control to play the important role. Last time we used TortoiseSVN (a free license of version control).


First you need to create a repository of the project to the server, this repository will serve as the main database. After that, select all your files which you want them to be included inside your database and commit it. Well, after that? You're done! Your first version of your project had just been created.

After your project database has seen setup, you can start to assign tasks to different programmers and different programmers should be working on different parts. For instance, programmer A working on A code and programmer B working on B code. It's recommended not to cross each other works.

Before the programmers can start their works, they need to update their workstation machine to the latest current server version.

In short, the procedures are as follow:
1) If you have not update your current project to the latest version as in server, UPDATE it.
2) After you have do some changes on your working file, COMMIT it to the server and the server will update itself with your file as the current version.

*Image taken from Wikipedia about version control

In conclusion, version control is very important where all the programmers should understand how it works. It helps you to keep track of your project progress or even rollback to older version in case any fatal bugs appeared and cannot be solved. Without version control, it very dangerous for your project!

This is a short brief about version control, hope you can get some ideas about what is it actually!