Tenev
Tenev

Reputation: 241

OpenGL - How Transparency works?

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?

Upvotes: 5

Views: 735

Answers (2)

Malte Clasen
Malte Clasen

Reputation: 5637

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.

Upvotes: 2

Dr. Snoopy
Dr. Snoopy

Reputation: 56377

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.

Upvotes: 2

Related Questions