Transparency in a texture

ok i know i am dumb but please can someone explain this to me. I have been searching and cannot find a suitable answer!

First of all i would like to pick my own colour that i use in a texture to not draw that colour on my quad. I know i can do this with the alpha test. I’m just not sure how to do it properly. I have been trying bright pink.

Another problem i am having is that i don’t think i am creating the tga texture correctly. How do i create a texture in photoshop with a proper Alpha channel that will work with my aplha test in my program?

If you can answer either question i will stop pulling out my hair! lol

I know i can use masks but i don’t really want to have 2 images for each texture i use! All i am doing is experimenting with quads on the screen for what you would call a 2d shooter.

Your time is very much appreciated!


Thats not quite how it works with GL (you are referring to a `colour-keying’ method).

In GL, as well as having a red, green and blue component for a texel, you can have an alpha component too. The alpha-test can not draw any given pixel where the given alpha value is zero (for example). To get rid of (say) all red texels, you will need some kind of pre-process to put zero alpha in those positions where the texel is the colour red.

Look for some TGA loading\editing tutorials.

Hope this helps.

The texture environment specifies how texture is applied. You might want to use texture alpha and modulate but this will multiply colors and produce alpha fragments.

There are other choices, from your description (and it’s not completely clear)it sounds like a DECAL texture environment might be what you’re looking for.

As for alpha in a texture. You need to write to a format which supports transparency and load it as a 4 component image. You can paint alpha in photoshop as part of an image or to a layer mask. You can then save the image to a PNG image and the transparency information will be preserved. Then you read the png as an RGBA memory representation and specify that as the image array for the RGBA texture. The key is chosing a format that supports alpha information and loading it correctly to your image array.