5
votes

Do i need Alpha channels for transparency to work in OpenGL? can i use glBlendFunc or anything else to make somehow the Black or White color transparent/not visible? if yes, how to do it?

2
Anything you do is very, very likely to be as complex or more so than alpha channels. If it's just to learn that's ok. So what/why are you trying to avoid using alpha channels for transparency?µBio
coz i already have images without alpha channels..Tenev
Give some more details tranparency in Opengl is too generic. What are you trying to do?ferosekhanj
duplicate of stackoverflow.com/questions/3392393/… , what was the matter with my answer ? P.S., If this question is "is there another way around", there is, but it's even more complicated.Calvin1602
its not a duplicate, the other question if for the texture/pixel removing, this one is for global opengl transparency... which i think is different.Tenev

2 Answers

2
votes

No, you don't need an alpha channel in your textures. Call discard in your fragment shader for all fragments that match your transparency rule.

2
votes

Yes, you need alpha channels to use transparency. You can emulate the behaviour of color keying using shaders, or processing the image and replacing the color key with pixels with alpha = 0.0.

Notice that GPUs always allocate RGBA textures, even if you want a RGB texture. The alpha channel is still present in hardware.