Surface Transparency Using Textures?

Is it possible to apply a texture with alpha values to a surface and use the alpha values to specify the transparency of the surface? Been experimenting with this for several hours and can not make it work. Apparently the alpha values serve only to mix the texture color with the polygon color. My alpha values are all either 0 or 1. Wherever they are zero, I want to see through the surface to other objects behind it. However, I fear that the ‘alpha’ referred to in the docs on glBlendfunc is not the ‘alpha’ as in r,g,b,a. Guess it comes down to this - Can transparency be specified on a pixel by pixel basis using a texture? Thanks.

generally it should work the way you want it to. You need a texture mode where the polygon color is modulated or replaced by the texture color, and when the texture has an alpha value, this alpha value will be used for blending. You need to specify the right blending function ( glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ), enable blending, and everything should work fine. I guess if it does not do so, simply one of the OpenGL states is not set correctly. Maybe you should post the code where you set up the textures and enable blend and draw the polygon.

example, look at the trees, I guess this is what you want to do, it works :
http://de.geocities.com/westphj2003/refl.html

Jan

[This message has been edited by JanHH (edited 01-02-2004).]

[This message has been edited by JanHH (edited 01-02-2004).]

If your trees were done by painting textures onto billboards and using the alpha value of the texture to make the billboard transparent, then you are doing what I want to do. I’ve been trying all kinds of combinations of sfactors and dfactors in Blendfunc and cannot get this to work. Must admit that what I read in the blue book on Blendfunc makes no sense to me. Perhaps I’ll post the code if I can’t get this to work after a few more hours. Thanks.

the right blend func is the one I posted and in fact all this is rather trivial. Are you SURE that your texture is in RGBA format (not RGB)?

There is really nothing mysterious about that. please post your code. Blend func is very straighforward once you get it (which took me some time, too).

And yes, the trees are done this way.

Jan

I got it working thanks to some key words from JanHH in his last post, which were, “All this is rather trivial”. That made me look at my code again to see how I might be making it too complicated. My problem was that I thought I had to use glTexEnv to set a texture env mode (like GL_DECAL). Turns out you don’t have to do that. In fact, it will screw you up if you do. As soon as I removed that call from my code and made one other trivial change, it worked! Thanks for your help JanHH.