I try to do the GrayScaleEffect in NGUI,I change the Shader(Transparent Colored),
Old Code:
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
return col;
}
New Code;
fixed4 frag (v2f i) : COLOR
{
fixed4 col;
if (i.color.r < 0.001)
{
col = tex2D(_MainTex, i.texcoord);
float grey = dot(col.rgb, float3(0.299, 0.587, 0.114));
col.rgb = float3(grey, grey, grey);
}
else
{
col = tex2D(_MainTex, i.texcoord) * i.color;
}
return col;
}
It work fine from 0.jpg to 1.jpg , see the picture
But it woule be some error 3.jpg when the gameobjct is child of UIScrollView also use soft clip of UIpanel.
Could you help me to do the Gray Effect i want?