May 30, 2009

Space Marine is Announced

It always feel so good to see my game is being announced because finally I can say what I'm working on.  I'm working on Warhammer 40K: Space Marine.  And this is the first video we released.  (The video which was circulating on YouTube last year has nothing to do with our game although it bears same name...)

Anyways, enjoy although I don't think you will enjoy more than I do while making this game :)

May 29, 2009

Math Behind Photoshop Blending

If you are a graphics programmer in the game industry, you will always have your beloved artists say something like this: "Hey, I want this Photoshop blaa-blaa-blending in our game!"

Then you will go to this link as I did for the overlay blend mode: http://www.nathanm.com/photoshop-blending-math/


Update: Found another article on ziggyware here: http://www.ziggyware.com/readarticle.php?article_id=228

Update: the only link that's still alive: http://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/

May 28, 2009

3D Pixel Perfect Object Picking with Hash

I ran into this article, which describes how to do object picking using a render target and a simple shader.  Yes, this is basically how we support pickings in game editors nowadays thanks to programmable shaders. =)

If you are using a 32-bit integer hash number to keep track of scene objects' name or something equivalent, you can make this system even better by directly storing that 32 bit number onto the render target.

so the code for setting the colour would be something like this:

int a = (hash >> 24) & 0xff;
int r = (hash >> 16) & 0xff;
int g = (hash >> 8) & 0xff;
int b = hash & 0xff;


Vector4 Colour;
Colour.X = r / 255f;
Colour.Y = g / 255f;
Colour.Z = b / 255f;
Colour.W = a / 255f;

Later, when you try to get a hash value on a certain pixel, you would just interpret the whole 32 bit value as integer like this:

int hash = Texture.getPixelAsInt(x, y);

Isn't this much better? :)