View Full Version : Alpha issues...
08-09-2001, 05:58 AM
I have a 2d textured quad overlaying my 3d scene. The problem I have is with the alpha. When the alpha of the texture is set to zero, the scene behind it is invisible. If I set it to half alpha, the scene is visible, but the quad is visible too (semi-opaque). And if it's at full alpha, the quad is completely opaque. I've tried using both glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and glBlendFunc(GL_SRC_ALPHA, GL_ONE), both giving me the same results. Any ideas?
08-09-2001, 06:12 AM
Ok, you've described what you have done and seen, but you fail to mention what you want to do. What do you want it to look like?
08-09-2001, 06:25 AM
Oops! That would be a good idea.
I want the 2d quad to be completely transparent, and have the 3d scene behind it show through.
Ok to me it sounds like you want parts of the texture to be visible but the rest not. If this is the case then do the following.
1. Create & save two textures.
The original and an inverted copy.
2. Load these up into your program.
3. Draw the quad using the blendfunc
using the inverted image that you created.
4. Now redraw the quad using this blendfunc
using your original image.
And there you go a nice masked image with an alpha level http://www.opengl.org/discussion_boards/ubb/smile.gif
I hope this is of some use to you even if this was not what you wanted. But give it a try anyway.
08-09-2001, 07:15 AM
That confuses me a bit. If it is to be completely transparent, why draw it at all? I suspect you mean that you want parts of the texture to be completely transparent and other parts completely or partially opaque. Correct? Also when you said
When the alpha of the texture is set to zero, the scene behind it is invisible.Do you mean that the quad was not visible and that the scene behind it was not drawn?
08-09-2001, 08:09 AM
Basically, there is a 3d scene behind a textured 2d quad (RGBA with alpha set to all zero). I have it set to capture mouse input and to modify the texture (more or less a 2d paint feature). So initially, I want the quad to be completely transparent, but I want to be able to "draw" on the quad. The problem is, when I set the alpha of the quad to zero, the 3d scene doesn't show! Weird. Sorry I'm so confusing today. Does that clarify my question?
08-09-2001, 08:12 AM
Ok, so that sounds simply like a depth buffering problem. You need to draw the quad after the 3D scene has been drawn, and draw the quad with depth testing disabled.
08-09-2001, 08:23 AM
But I DO disable depth testing, and if the alpha of the quad is set to 50%, you can see the scene behind the semi-opaque quad. It's like the alpha of the 3d scene is linked to the alpha of the quad.
08-09-2001, 08:52 AM
Ok, something is out of whack. Here is how I would do what you wanted to do:
1. Get mouse, and modify texture if necessary, to set a texel, set its RGB triplet to whatever you want, and its ALPHA to 1. This is so texels with ALPHA 0 are not drawn and those with ALPHA 1 are drawn. Upload any changes to quad texture
2. Clear color buffer and depth buffer
3. Enable depth testing
4. Draw 3D scene
5. Disable depth testing
6. Enable alpha testing, alpha func > 0
7. Draw quad
8. Disable alpha testing
9. Repeat until done.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.