I would like to know why we would use alpha blending in that shader for just rendering a sprite, which is just a texture ? What is tint color ? Why we multiply the alpha value by the color here ?

fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color; // why ?
c.rgb *= c.a; // why ?
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
}

{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}

Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Blend One OneMinusSrcAlpha

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile DUMMY PIXELSNAP_ON
#include "UnityCG.cginc"

struct appdata_t
{
float4 vertex   : POSITION;
float4 color    : COLOR;
float2 texcoord : TEXCOORD0;
};

struct v2f
{
float4 vertex   : SV_POSITION;
fixed4 color    : COLOR;
half2 texcoord  : TEXCOORD0;
};

fixed4 _Color;

v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color * _Color;
#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap (OUT.vertex);
#endif

return OUT;
}

sampler2D _MainTex;

fixed4 frag(v2f IN) : SV_Target
{
fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
c.rgb *= c.a;
return c;
}
ENDCG
}
}
}

• Tints are used often in sprites. This helps change the colour very quickly without having to change the texture itself, or make a copy. Alpha blending may be used when drawing sprites. For example, you'll probably want alpha blending for 2D particle effects. – Ben Jan 19 '15 at 20:54
• So If I just want to draw a 2D GUI Texture(an image) is it ok to remove the tint and the alpha blending from that shader ? – andre Jan 19 '15 at 20:57
• Yeah, if you don't want these features, I'd assume so. – Ben Jan 20 '15 at 1:15

Multiplying the texture's RGB with the A could be used to give you a fade in/out effect. The alpha channel in the RGBA is a normalized value in the [0,1] range, so if you were to multiply the RGB with an alpha of say 0.2, you would get a very dark sprite. Multiply it by 1 and you will get the texture color as it is. You could get this same effect by multiplying the color with a back/white tint, BTW.