Separate Blending Functions

It is also possible to determine how the RGB channels are going to be combined independently from the alpha channels. For that, we use the gl.blendFuncSeparate function.

We define two independent functions this way:

color = S.rgb * sW.rgb + D.rgb * dW.rgb;
alpha = S.a * sW.a + D.a * dW.a;

More precisely:

  • sW.rgb: Source scaling factor (only RGB)
  • dW.rgb: Destination scaling factor (only RGB)
  • sW.a: Source scaling factor for the source alpha value
  • dW.a: Destination scaling factor for the destination alpha value

Then, we could have something such as the following:

color = S.rgb * S.a + D.rbg * (1.0 - S.a);
alpha = S.a * 1.0 + D.a * 0.0;

This would be translated into code as follows:

gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ZERO);

The parameters for the gl.blendFuncSeparate function are the same as gl.blendFunc. You can find more information on these functions later in this section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.202.167