赞
踩
Blending is used to make transparent objects.
When graphics are rendered, after all Shaders have executed and all Textures have been applied, the pixels are written to the screen. How they are combined with what is already there is controlled by the Blend command.
混合不仅仅用于透明度混合,我们要开启混合,在Unity中设置的同时也进行了开启,但如果在其他图形API中是需要我们自己手动开启的。
源颜色(Src,source color):由片元着色器产生的颜色值
目标颜色(Dst,Destination color):从颜色缓冲中读取到的颜色值
这里的颜色值都是包括RGBA四个通道
Turn off blending (this is the default)
默认设置,关闭混合
示例:
Blend Off
Configure and enable blending. The generated color is multiplied by the SrcFactor. The color already on screen is multiplied by DstFactor and the two are added together.
开启混合并设置混合因子。源颜色会乘以SrcFactor,而目标颜色会乘以DstFactor,然后把两者相加再存入颜色缓冲中
示例:
Blend SrcAlpha OneMinusSrcAlpha
透明度混合的命令
Same as above, but use different factors for blending the alpha channel.
和上面几乎一样,只是使用了不同的因子来混合透明通道
示例:
Blend SrcAlpha OneMinusSrcAlpha, One Zero
混合后输出颜色的透明度就是源颜色的透明度
Instead of adding blended colors together, carry out a different operation on them.
并非是把源颜色和目标颜色简单相加后混合,而是使用Op(操作命令)对它们进行其他的操作
示例:
BlendOp Min
Blend One One
变暗效果(Darken)
Same as above, but use different blend operation for color (RGB) and alpha (A) channels.
和上面几乎一样,只是使用了不同的混合操作来分别处理RGB通道和透明通道
示例:
BlendOp Add, Min
Turns on alpha-to-coverage. When MSAA is used, alpha-to-coverage modifies multisample coverage mask proportionally to the pixel Shader result alpha value. This is typically used for less aliased outlines than regular alpha test; useful for vegetation and other alpha-tested Shaders.
All following properties are valid for both SrcFactor & DstFactor in the Blend command. Source refers to the calculated color, Destination is the color already on the screen. The blend factors are ignored if BlendOp is using logical operations.
The value of one - use this to let either the source or the destination color come through fully.
因子的值为1。
The value zero - use this to remove either the source or the destination values.
因子的值为0.
The value of this stage is multiplied by the source color value.
因子为源颜色值。当用于混合RGB的混合等式时,使用SrcColor的RGB分量作为混合因子;当用于混合A通道的混合等式时,使用SrcColor的A分量作为混合因子
The value of this stage is multiplied by the source alpha value.
因子为源颜色的透明度值(A通道)
The value of this stage is multiplied by frame buffer source color value.
因子为目标颜色值(未混合前缓冲区中的颜色值)。当用于混合RGB通道的混合等式时,使用DstColor的RGB分量作为混合因子;当用于混合A通道的混合等式时,使用DstColor的A分量作为混合因子
The value of this stage is multiplied by frame buffer source alpha value.
因子为目标颜色的透明度值(A通道)
The value of this stage is multiplied by (1 - source color).
因子为(1-源颜色)。当用于混合RGB通道的混合等式时,使用结果的RGB分量作为混合因子;当用于混合A通道的混合等式时,使用结果的A分量作为混合因子
The value of this stage is multiplied by (1 - source alpha).
因子为(1-源颜色的透明度值)
The value of this stage is multiplied by (1 - source alpha).
因子为(1-目标颜色)。当用于混合RGB通道的混合等式时,使用结果的RGB分量作为混合因子;当用于混合A通道的混合等式时,使用结果的A分量作为混合因子
The value of this stage is multiplied by (1 - destination alpha).
因子为(1-目标颜色的透明度值)
The following blend operations can be used:
Add source and destination together.
将与分别与自己的混合因子相乘后的源颜色和目标颜色相加。默认的混合操作。
O_rgb=SrcFactor ×S_rgb+DstFactor ×D_rgb
O_a=SrcFactorA ×S_a+DstFactorA ×D_a
Subtract destination from source.
用混合后的源颜色减去混合后的目标颜色。
O_rgb=SrcFactor ×S_rgb−DstFactor ×D_rgb
O_a=SrcFactorA ×S_a−DstFactorA ×D_a
Subtract source from destination.
用混合后的目标颜色减去混合后的源颜色
O_rgb=DstFactor ×D_rgb−SrcFactor ×S_rgb
O_a=DstFactorA ×D_a−SrcFactorA ×S_a
Use the smaller of source and destination.
使用源颜色和目标颜色中较小的值,是逐分量比较的。
O_rgba=(min(S_r,D_r ),min(S_g,D_g ),min(S_b,D_b ),min(S_a,D_a ))
Use the larger of source and destination.
使用源颜色和目标颜色中较大的值,是逐分量比较的。
O_rgba=(max(S_r,D_r ),max(S_g,D_g ),max(S_b,D_b ),max(S_a,D_a ))
仅在DirectX11.1中支持,详见
https://docs.unity3d.com/Manual/SL-Blend.html
正常(Normal),即透明度混合
柔和相加(Soft Additive)
正片叠底(Multiply),即相乘
两倍相乘(2x Multiply)
变暗(Darken)
变亮(Lighten)
滤色(Screen)
同上
线性减淡(Linear Dodge)
https://docs.unity3d.com/Manual/SL-Blend.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。