reprinted from the Wind Yu Chong Unity3d Tutorial College
Introduction: This and the next talk mainly about alpha is transparent channel related content. RGBA, where the final display on the screen is only RGB, which is a red-green-blue color, and Alpha does not display any color. A is just a secondary color operation, especially a multi-layer operation. For example, in the case of a single layer (1,1,1,0.8) the output is (1,1,1) *0.8 that is light gray (0.8,0.8,0.8), and (0.8,0.8,0.8) is equivalent. But if it is no longer a single layer and the background is green (0,1,0,1), ( 0.8,0.8,0.8) do not know how to calculate, and (1,1,1,0.8) know. Can't read this quote? It doesn't matter, look down, when you finish the fifth and sixth talk and then come back to see the nature can understand deeply.
What is a channel:The channel is a 8-bit grayscale image, capable of displaying 256 shades of gray, used to represent the RGBA value of the color. R=red Red, G=green Green, B=blue blue, A=ALHPA transparent value, RGB is the primary color channel, A is transparent channel. In the channel, a white instead of transparent indicates the part to be processed (selection area), and a black representation of the part that is not to be processed (not the selection area) the range of values for all channels is [0,255], but the value range in shader is [0,1], 0 and 1 resolution corresponds to 0 and 255
what is an alpha channel:Definition: The General graphics card has a 32-bit bus, the additional 8-bit signal is used to save the invisible transparency signal for easy processing, this is the alpha channel. White alpha pixels are used to define opaque color pixels, while black alpha pixels are used to define transparent pixels, and gray levels between black and white define translucent pixels. In short: The alpha channel takes the same value as [0,255] and shader[0,1], the smaller the value, the more transparent the value, the greater the opacity. In shader, 0 is transparent, nothing is present, and the editor is black. 1 is opaque, all are displayed, the editor is displayed as white.
What is Alpha Test:Alpha Test, Chinese is the transparency test. In short, the alpha value of the point color value (that is, the output half4 of the previous frag) is compared to the fixed value in the V&f shader in the last fragment function output. The alphatest statement is usually at the starting position in pass{}.
Syntax:First: alphatest Off: No test, full render second: alpha-comparator target alpha value where the target Alpha value range is 0 to 1, you can also use parameters such as alphatest [VarName].
comparison characters:(The target alpha value is recorded as X) Always full render (any x value) never render lequal point with alpha value less than x when the alpha value of the rendered Geuqal point is greater than X at the greater point when the alpha value of the render-point is greater than or equal to X. The alpha value of the rendered equal point equal to X when the alpha value of the rendered notequal point is equal to X is not equal to X when the render example: Alphatest never 0 is not rendered at all (this 0 can be any value, but must be filled) alphatest always 0 Full render (this 0 can be any value, but must be filled) alphatest off full render alphatest Greater 0.4 when alpha is greater than 0.4 rendering, the disadvantage is that the edge is too sharp and the display is incomplete, the Alpha less than 0.4 portion is Ignore the alpha blend edge soft, but the center is too soft, no solid feeling alphatest Greater 0.4/alphatest lequal 0.4 two parts, greater than 0.4 not mixed, less than 0.4 mixed. The effect is both a solid feeling and a softer edge.
Unity3d Tutorial Shader: The 12th Alpha test