static_rtti
static_rtti

Reputation: 56262

Per-component alpha-channels with OpenGL?

Is it possible to perform blending with one alpha channel per component (one for red, one for green and one for blue) with OpenGL? If not, what are some possible workarounds?

Upvotes: 5

Views: 904

Answers (4)

Anonymous
Anonymous

Reputation: 2172

You are probably looking for: GL_ARB_blend_func_extended

Upvotes: 0

basszero
basszero

Reputation: 30014

You could do this with a pixel shader, but you'd need to find a way to store/access per component alpha values. You could store them in a texture and treat the normal color components as the alpha values for the corresponding color.

What effect/output are you trying to achieve?

Upvotes: 1

Bahbar
Bahbar

Reputation: 18015

What you're describing is not possible with OpenGL.

That said, considering that you're new to OpenGL, maybe what you're describing is not exactly what you're after ?

Blending is the step that happens once you decided what color your current fragment (usually coming from a triangle) is supposed to have. That color needs to be merged with the previous color in the frame-buffer. Are you sure that's what you're after ?

Upvotes: 0

Andreas Brinck
Andreas Brinck

Reputation: 52519

This isn't something that's directly supported. It's fairly easy to achieve on your own though:

  • Render your triangle (or whatever) using the 3-channel "alpha" texture and glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR)
  • Enable multitexture and set the "alpha" texture to modulate your rgb texture
  • Render your triangle with glBlendFunc(GL_ONE, GL_ONE)

Upvotes: 3

Related Questions