View Full Version : Partly transparent textures (and planes)

06-26-2009, 06:32 AM

I am not sure if there is a word for what I am trying to do. What I am trying to do is to map a texture on a rectangular plane (which works). But I want to be the texture and the plane to be partly transparent to form randomly formed objects.

I think that I could use the alpha value to do this.
But how do I generate and store the alpha values for existing textures. Are there any simple examples for this? Or is there perhaps a better way to do this?

Thank you for all replies,


06-26-2009, 07:03 AM
Use RGBA texture format and for some texels set their alpha values to be 0 to make them opaque, some as 0.5 (translucent)
and some as 1.0

or you can use some sort of mask or a second texture designed such as when blended with the first texture gives the desired effect.

06-26-2009, 08:22 AM
Thanks, I set the alpha value of the texture to transparent in some parts.

How do I have to set up the other parameters: glTexImage and glTexEnv

Thank you for your help.


06-26-2009, 08:28 AM
What I am searching is something like this:
(found on http://www.glprogramming.com/red/chapter06.html#name5)

Do you know code examples to generate sth. like this?

06-26-2009, 12:00 PM
I have transparent effects now, but the problem is, that the effect I have is always affects the whole image.
I just want to habe partly transparent images. I set the alpha values in this way:

for(int i = 0; i < 256; i++)
for(int j = 0; j < 256; j++)
data2[i*256*4+j*4+0] = data[i*256*3+j*3+0];
data2[i*256*4+j*4+1] = data[i*256*3+j*3+1];
data2[i*256*4+j*4+2] = data[i*256*3+j*3+2];
data2[i*256*4+j*4+3] = (BYTE)255;
if(j > 128) data2[i*256*4+j*4+3] = (BYTE)0;

data is a RGB image.

Someone got an idea?

06-26-2009, 12:08 PM
The figure you drew is called Billboarding. For tutorial on this refer to http://www.lighthouse3d.com/opengl/billboarding/. (http://www.lighthouse3d.com/opengl/billboarding/)

Try RGBA instead of RGB. The code above does not have effect if your format is RGB.

06-26-2009, 12:12 PM
Assuming you want to rotate your texture mapped rectangle then you can set your rectangle's metallic properties ( Ch 5 red book) where when a side of it moves away from fixed light position, can fade and the one that is near is bright.

06-26-2009, 12:53 PM
Thank you for the help. Now it works. I think it was a problem of OpenGL settings. I will check it later.

I have been at least ten times on the billboard page you posted but only read the first line: " Billboarding is a technique that adjusts an object's orientation so that it "faces" some target, usually the camera. " So I thought it is a kind of camera adjusting... ;-)

The code I posted is for making RGBA out of RGB.

Now it works... yepie!

07-25-2009, 09:44 PM
I've the same problem. I want to fade in text with transparent background ( or tree same as above ) Now I get all texture region white instead of only seeing the white writing(tree whatever)
Could you give me some code snippets for help?
Many thanks