Shader "N/T" { Properties { _Color ("Texture to blend", Color) = (1,1,1,1) } SubShader { Tags { "Queue" = "Transparent" } ColorMask R Pass { Blend DstColor one CGPROGRAM #include "UnityCG.cginc" //#pragma exclude_renderers gles #pragma vertex vert #pragma fragment frag float4 _Color; float4 vert( appdata_base v ) : POSITION { return mul( UNITY_MATRIX_MVP, v.vertex ); } float4 frag(float4 pos:POSITION):COLOR { return _Color; } ENDCG } } Fallback Off }
_Colr为(1,1,1,1)时,ColorMask R情况下,最终颜色计算方式
(1,0,0) * (bgColor.r,bgColor.g,bgColr.b) + (bgColor.r,bgColor.g,bgColr.b) * (1,1,1)
最终颜色 = frag计算结果 * 帧缓冲中已有颜色 + 帧缓冲中已有颜色*1
注意一点在ColorMaskR 条件下 frag计算结果由(1,1,1)变为(1,0,0)