Chroma Keying

What’s the easiest way to allow chromakeying of textures? Is there an extension that allows you to do this? Or do you need to set alpha’s for all texels?

Thanks in advance,
-Alvion

Yes, you need to set alphas for textures. Chromakeying is only a “hack” used in the film industry to convert a colour image to a colour image and a matte. The matte is the alpha channel, and you shouldn’t really be using a colour index as a key to transparency if you can possibly avoid it. IMHO.

cheers
jOhn

ARg! I have read somewhere that 3DLabs wrote an extension to support this… hoped maybe NVidia and gang would have followed suit. I agree it’s not the cleanest way to allow for an alpha channel, but adding 8 bits to all my textures just to achieve this effect isn’t too appealing either…

Thanks tho,
-Alvion

Sorry to barge in, but what’s chromakeying?

Chromakeying is when you can specify a color (say, 0x000000) as your transparent mask. Then, whenever a pixel is supposed to be drawn in this color, it will instead be drawn transparent (or, as it were, not drawn at all). You can use 0x000001 for black where black needs to be shown.

You can do this can’t you? Isn’t there a color-test available. (GL_NOT_EQUAL, 0,0,0) for instance, would make black transparent. I’m sure I read somewhere that there’s a way to test the color.

Well, seeing as how I already went and changed texture formats to 5-5-5-1 to do this… not so sure I’ll use it anyway… but I would be VERY interested to know how if you could find it…

-Alvion

I’m afraid that OpenGL doesn’t have a glColorTest() functionality.

I think you can NOT implement chroma key on unextended OpenGL, so you have to use RGBA texture formats.

If 5-5-5-1 is the issue, one can use S3 texture compression and ARB_texture_compression functionality.
It works fine.

And one other issue with chroma keying is that the only texture filter available will be GL_NEAREST.

AFAIK most cards support 5551 format. So while the textures take up more space on disc (unless you use your own image format) they’ll only be bit pit per pixel bigger. Thats not too bad is it?

Paul.

No, the big thing was… I was using 24bit RGB before… and changing to 32bit was just a little ridiculous considering the engine I am writting this for wont use the alpha channel for anything except on or off. So basically, I had to go through and change everything to 5551 to support this… kindof a drag. Thanks for all the help though (this is only my 4th day using opengl… so I’m still quite new to this).

-Alvion

I don’t know is it too bad for Alvion, but it was too bad for us. 5-6-5 and 5-5-5-1 texture formats too differ, believe me.
So we are using S3TC - it does look good enough but uses much less texture memory.