Per-component alpha-channels with OpenGL?

。_饼干妹妹 提交于 2019-12-23 12:08:03

问题


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?


回答1:


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)



回答2:


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?




回答3:


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 ?




回答4:


You are probably looking for: GL_ARB_blend_func_extended



来源:https://stackoverflow.com/questions/2818351/per-component-alpha-channels-with-opengl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!