I recently needed a greyscale shader, so I took the NGUI Premultiplied Colored shader, and changed the fragment shader to be this
half4 frag (v2f IN) : COLOR
{
half4 col;
half4 colt;
col = tex2D(_MainTex, IN.texcoord);
colt = col * IN.color;
float grey = dot(col.rgb, float3(0.299, 0.587, 0.114));
col.rgb = (IN.color.r==0) * float3(grey, grey, grey) + (IN.color.r!=0) * colt.rgb;
col.a = colt.a;
return col;
}
Everything works great on UISprites, however it's been causing weird alpha issues with UI2DSprites. I did a quick
side-by-side comparison, with the top images being UISprites in an atlas and the bottom sprites being UI2DSprites.
Even though I know it's not efficient for draw-calls' sake, my game uses a good amount of UI2DSprites due to loading a lot of character assets from assetbundles, and the individual bundles are small enough that it doesn't make much sense to atlas them.
Is there something I'm doing wrong with the shader? Or is there something else I'm doing wrong?