With regard to transparency, opengl/es can be easily achieved through blend (process color), the basic principle of the process is to draw the object's color and the screen has been painted on a certain proportion of the color to mix, the final color looks like translucent.
To use blending, first enable by using the Glenable function
1 glenable (gl10.gl_blend);
Then use the Glblendfunc to set the blending method to be used
1 Glblendfunc (Sfactor, dfactor);
Sfactor and Dfactor are enumerated constants that represent the proportion of the source and target colors as they are mixed. Among the sfactor values are: Gl_zero, Gl_one, Gl_dst_color, Gl_one_minus_dst_color, Gl_src_alpha, Gl_one_minus_src_alpha, GL_DST_ ALPHA, Gl_one_minus_dst_alpha, gl_src_alpha_saturate; dfactor desirable values include: Gl_zero, Gl_one, Gl_src_color, GL_ONE_MINUS_SRC_ COLOR, Gl_src_alpha, Gl_one_minus_src_alpha, Gl_dst_alpha, Gl_one_minus_dst_alpha.
The following descriptions and the values of R, G, B, and a of the colors involved in the formula refer to floating-point forms, that is, the range is between 0.0f–1.0f.
When calculating a process color, the coefficients of the source and target colors are derived from the above enumeration, and then multiplied by the source and target colors (the product is greater than 1 o'clock 1), and then the resulting results are added. So if the coefficients of the Rgba four components based on the above enumeration are assumed to be the source SfR, SfG, SfB, SfA, Target DfR, DfG, DfB, DfA, source and target color component values are respectively SR, SG, SB, SA and DR, DG, DB, DA The resulting color of RR, RG, RB, RA, respectively, is:
RR = SR * SfR + DR * DfR
RG = SG * SfG + DG * DfG
RB = SB * SfB + DB * DfB
RA = SA * SfA + DA * DfA
The value of the above RR, RG, RB, RA, if greater than 1, is the final value of 1.
Then look at XfR, XfG, XfB, XfA (x = s/d) is how to get out.
Factor enumeration XfR, XfG, XfB, XfA
Gl_zero 0, 0, 0, 0
Gl_one 1, 1, 1, 1
Gl_src_color SR, SG, SB, SA
Gl_dst_color DR, DG, DB, DA
Gl_one_minus_src_color 1-SR, 1-SG, 1-SB, 1-sa
Gl_one_minus_dst_color 1-dr, 1-DG, 1-db, 1-da
Gl_src_alpha SA, SA, SA, SA
Gl_dst_alpha da, Da, Da, da
Gl_one_minus_src_alpha 1-sa, 1-sa, 1-sa, 1-sa
Gl_one_minus_dst_alpha 1-da, 1-da, 1-da, 1-da
Gl_src_alpha_saturate I, I, I, 1 *
The last I value in the top table is min (SA, 1-da)
According to the above formula,
Glblendfunc (Gl_one, Gl_one); That is, the source and the target color of Rgba are added separately.
Glblendfunc (Gl_one, Gl_zero); That is, only the source color, which is also the default value.
Glblendfunc (Gl_src_alpha,gl_one_minus_src_alpha); is a more typical translucent effect, if the source color alpha is 0, the target color is taken, if the source color alpha is 1, the source color, otherwise depending on the source color of the alpha size is taken part. The larger the alpha of the source color, the more the source color is, the more the resulting source color is, and the more the target color is "through" the smaller the source color's alpha.
In addition, in the general rendering process, will have the translucent effect of rendering to the back, first the opaque part of the depth test enabled in the case of rendering finished, and then turn off the depth test write (Gldepthmask (false)), and render the translucent part. This will not occur due to the translucent and the surface near the lens is first rendered when the pollution depth buffer.
[iOS] [Opengles]opengles Transparency Issues on iOS