View Full Version : Transparent bitmaps
I never noticed this before (so why is it happening now?) When I use a bitmap with one color's alpha set to 0, I enable blending (SRC_ALPHA, SRC_ONE_MINUS_ALPHA) and the bitmap's colors are reversed. The only solution was to use the negative of the bitmap.
I see this on Matrox Millenium II and GeForce (I) but when I run the exact same exe on a machine with Matrox G400, the colors do not get reversed.
06-22-2000, 06:52 AM
That's really weird, with the alpha set to 0 and using that blending function, I'm surprised you're seeing anything at all! Or maybe I'm thinking of something else. Dunno.
Sorry, I should clarify. One color's alpha is set to 0, the other colors are alpha 1.0. The effect I am going for is billboarding.
When I set the glTexEnvf(...,...,GL_BLEND); The texture is the negative, but when I use GL_DECAL the texture is fine (with no transparency).
06-22-2000, 10:39 AM
How many components are in the textures you are using? In GL_BLEND mode, they can have 2 components, luminance and alpha, or just 1 component, luminance. If you try using textures with more the 2 components then very bizarre things can happen and will likely vary from one OpenGL implementation to the next. I would suggest using GL_MODULATE with the fragment color set to (1.0, 1.0, 1.0, 1.0), and blending function as (gl_src_alpha, gl_one_minus_src_alpha). If the billboards are opaque (except for cutout regions) then you might want to enable alpha testing. Alpha testing would preserve the z-buffer values in the regions behind the cut outs allowing you to draw them in any order.
[This message has been edited by DFrey (edited 06-22-2000).]
06-23-2000, 05:03 AM
Thanks that did it.
BTW, Is this the fastest way to perform transparency for billboarding?
SuperFly (Formerly StinkySal)
06-23-2000, 06:24 AM
The blending mode should not be any slower than any other blending mode, so as far as I know, yes. Although if you are using alpha testing, that does slow it down a bit or at least that is what I have observed. If you are using alpha testing and you want to see if the alpha testing is being too big of a hit, then another option is to depth sort the billboards, and render them from far to near with depth writes turned off but depth testing still enabled. This can be tricky though, since you'd also have to sort any transparent non-billboard polys with the billboard polys too, since transparent polys are in general best rendered this way too. For example my engine draws all background polys first, opaque depth buffered polys next. Then I depth sort the billboard and transparent polys, and draw them from far to near with depth writes disabled. Finally I draw all foreground polys (usually the HUD polys) with depth testing disabled. There are other special polys which have thier own place in the drawing order that I haven't mentioned but this should give you an idea on how to proceed with your project (not that know what it is, I'm only assuming its a 3D engine).
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.