Fuzzyzilla
Fuzzyzilla

Reputation: 356

GL_BLEND - Change which channel is used as Alpha

If I have a Renderbuffer that uses a color format without alpha, for example GL_RG8, how can I tell the alpha blender to use the green channel for alpha? This can be done in textures using a swizzle mask, but as renderbuffers don't support those, what can I do?

My current blendFunc is GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA.

Upvotes: 0

Views: 293

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473212

Each user-defined output of the fragment shader contains 4 channels: RGBA. This is true regardless of the image format of the destination that the output will write to. These outputs are the source colors for the blend operation.

So just write to the alpha of the output as normal. It doesn't matter that the alpha won't be written to the framebuffer image. It's still a part of the source color, so it can still be used for blending purposes.

Upvotes: 3

Related Questions