0

I have a need where I need to have separate blending for alpha channel but its not working.

Let me explain with my test.

Alpha blending is enabled and I have set color and alpha write mask to true.

1) I am clearing my buffer with glClear(0,0,0,1)

2) I am drawing a big 2D quad which will have its color blend to half and will "set destination alpha values to zero" (-> this is what I need to achieve !) Src Color is (1,1,1,0.5)

Here are the blend parameters I am setting

transparencyData.color_blendfunc     = BlendInfo.BLEND_FUNC_ADD
transparencyData.alpha_blendfunc     = BlendInfo.BLEND_FUNC_ADD
transparencyData.colorSrc_blendfactor = BlendInfo.BLEND_FACTOR_SRC_ALPHA
transparencyData.colorDst_blendfactor    = BlendInfo.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
transparencyData.alphaSrc_blendfactor    = BlendInfo.BLEND_FACTOR_ZERO
transparencyData.alphaDst_blendfactor    = BlendInfo.BLEND_FACTOR_ZERO

3) I am drawing a smaller 2D quad inside the above quad Src Color is (1,1,1,1) Here are the blend parameters I am setting

transparencyData.color_blendfunc     = BlendInfo.BLEND_FUNC_ADD
transparencyData.alpha_blendfunc     = BlendInfo.BLEND_FUNC_ADD
transparencyData.colorSrc_blendfactor = BlendInfo.BLEND_FACTOR_ONE_MINUS_DST_ALPHA
transparencyData.colorDst_blendfactor    = BlendInfo.BLEND_FACTOR_DST_ALPHA
transparencyData.alphaSrc_blendfactor    = BlendInfo.BLEND_FACTOR_ONE
transparencyData.alphaDst_blendfactor    = BlendInfo.BLEND_FACTOR_ZERO

Now while quad rendered by step 2 appears half blended, my desired need where it sets the final alpha value of the destination to zero is not happening. How I know this is because the quad rendered in step 3 should appear if destination alpha is zero and will not appear if destination alpha is one. This is making me believe that either the alpha blending which might be happening is not working and getting written to the destination or I am doing something not right !!!

I am using glBlendEquationSeparate and glBlendFuncSeparate for this purpose.

Can you please shed light and help me in what I am trying to do ?

genpfault
  • 51,148
  • 11
  • 85
  • 139
madan kandula
  • 460
  • 5
  • 22
  • Make sure you actually have an alpha channel in your color buffer. – derhass Jun 09 '14 at 16:42
  • Could you pleas add the result image as this might be much easier to resolve with it. By the way try to read some pixels on areas where you believe might be an issue after every step to see what is truly going on. – Matic Oblak Jun 10 '14 at 05:46

0 Answers0