PDA

View Full Version : Colorkey


jorgemonti
2005.04.21, 06:41 AM
Hi all!

I'm back with a new question :-)

Is it possible in openGL to set a mask, filter, etc to block a specific
color to be put in the color framebuffer, without using the alpha channel.
It's the typical example of sprites where you reserve a color to be the
transparent color, and when you draw the sprite this color is skipped.

Now I get this effect with blending because I can set the alpha channel
to transparent for the specific color and opaque for the rest, but this
implies using alpha blending, and i'm trying to avoid it.

Any comment is welcome,
Thanks

OneSadCookie
2005.04.21, 07:49 AM
I'm 99% certain you'd need a fragment program to do that.

If your images are pixel-aligned, you can do alpha testing without blending.

phydeaux
2005.04.21, 10:29 AM
Instead of an image alpha channel you can use a mask as shown here, (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20) but the mask takes up just as much space, so I don't see why you'd bother. As OSC said, if you're trying to avoid blending because you don't want to make anything partially transparent, you can use an alpha test function, or set up your texture filtering to use NEAREST instead of interpolating (you can get a sort of retro effect.)

jorgemonti
2005.04.21, 12:30 PM
Thanks for the answers!

I've tried the mask technique and it's the result i'm trying to achieve.
Now I'll try the fragment program to avoid the redundance of graphic
file to generate, because i'm masking one colour, maybe the argument
to the fragment program? I don't know anything of fragment programs.
Any link, code, etc is welcome :-)

Thanks