Interpolative Blending

If we set sW to S.a and dW to 1 - S.a, then we get the following:

color = S * S.a + D *(1 - S.a);

This will create a linear interpolation between the source and destination color using the source alpha color, S.a, as the scaling factor. In code, this is translated as the following:

gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);

Interpolative blending allows us to create a transparency effect as long as the destination fragments have passed the depth test. As expected, this requires that the objects be rendered from back to front.

In the next section, we will play with different blending modes on a simple scene composed of a cone and sphere.

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

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