Make color transparent

I’ve loaded some pictures and used them as textures.
But I want to look through one color in my hall scene(the color(1.0, 0.0, 1.0)), so i can see the underlieing texture.
I think it should be done with blending and the alpha value, but I have no idea how to do it(the files that I’ve loaded don’t support alpha values).
If anyone knows how to do it, please let me know.

The only thing I can think of is using a fragment program to filter out fragments of that color.

In the fragment program you test the RGB value, it it’s 1.0,0.0,1.0 you discard the fragment.

You’re right though, you should really use textures with an alpha channel.

I think too that RGBA textures should be best.

One solution consists on changing the format of your picture and do the work in order you color to be transparent (gimp can do that). TGA is a good format to manage transparency.

Another solution would consists on modifying or adding new functions to your texture loader so that you can do the manipulations you want.

Ok, thank your for your replies.
But the reason i did not used a file with alpha values support was i did not get the effect i wanted.
I’ve loaded the image using QTs QImage class, but when i display the texture it’s black where it should be transparent(the color of the QUAD is (0.0, 0.0, 0.0, 0.0) that should be completly transparent).

If the surface you’re mapping your texture onto has an alpha of 0.0 you won’t see anything.

try using a color of (1.0,1.0,1.0,1.0) and using GL_MODULATE to do your texturing for starters.

also, have you enabled blending and defined a blending function?
use glEnable(GL_BLEND);
and check out manual on glBlendFunc();

Ok, thanx
I’ve now enabled blending, and have set the texture combining thing to GL_MODULATE, changed the quad color to (1.0, 1.0, 1.0, 1.0) and my blending function looks like this:


But when i run the program, everything is much lighter and looks kinda different.
So how can i have the original colors but still a transparent picture?
Thanx Hylke

Try using this for blending:
might be what u want. Also remember to turn off blending when you don’t need it (and it’s also good practice to draw your transparent objects last in your display function)

Try GL_DECAL instead of GL_MODULATE.

that GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA did the trick.
Thanx Hylke