hybrid

OpenGL renders the color values in the color cache, and the depth values of each fragment are also placed in the depth buffer. When the depth buffer is turned off, the new color simply overwrites the existing color values in the original color buffer. When the depth buffer is turned on again, the new color fragments replace the original color fragments only if they are closer to the adjacent clipping plane than the original values.

glEnable(GL_BlEND);
Copy the code

Combining colors

Target color: color values already stored in the color cache Source color: Color values entered as the result of the current render command

When blending is enabled, the combination of source and destination colors is controlled by blending equations. By default, the mixture equation looks like this:

Cf = (Cs * S) + (Cd * D); Cf: color of the final calculation parameter Cs: source color Cd: target color S: source compounding factor D: target blending factorCopy the code

Mixed factor

To set the blending factor, use the glBlendFun function:

glBlendFunc(GLenum S,GLenum D); S: source mixing factor D: target mixing factorCopy the code

In the table, R, G, B and A represent red, green, blue and alpha respectively. The subscripts S and D in the table represent the source table and C represent the constant color in the target table (black by default).

From logic education