OpengGL provides mixing functions in 15 for developers to use quickly, including (mixing coefficient, mixing factor, enumerated values of comments):
Turn on the mixed mode in the actual application scenario. Draw a color W(0.3, 0.4, 0.7, 0.5) on the layer first, and then draw a color X(0.8, 0.2, 0.3, 0. 1). If the mixing function is glblendfunc (GL _ src _ alpha, GL _ one _ minus _ src _ color) and the operator is glblendequeation (GL _ func _ addfunc _ add), the mixing result is calculated as follows:
The condition is the same as that of 1, except that the mixing function adopts glblendfuncspective(GL _ one, GL _ one _ minus _ src _ alpha, GL _ one, GL _ one _ minus _ dst _ alpha), which can be known through decomposition.
Due to the limitation of OpenGL's own mixed algorithm interface, it is impossible to customize the extension except the above contents, so developers can also complete the mixing in the shader. However, this method not only needs the color buffer data of the current frame as the shader input, but also needs the color buffer data of the previous frame, so that the custom algorithm can complete the blending. Therefore, it has some shortcomings in time and space, but it is a hybrid algorithm with high degree of freedom and customization. The use of blending in shaders will be introduced as an example in a future article.