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 :)
I once said "unless side-tracked, this will be my professional blog on game development". Scratch that. I will just write about whatever I do: coding, ranting and being an emo
May 30, 2009
May 29, 2009
Math Behind Photoshop Blending
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? :)
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? :)
Subscribe to:
Posts (Atom)