I have a really simple shader (below) which should, as far as I can tell, allow me to change the _Color property at run time, and have the alpha reflect the changes. Yet it doesn’t. I can change the color, and the color on the mesh changes, but the alpha is completely unaffected. The mesh has vertex alpha, and by toggling that in the shader I can see that the alpha is working as intended right up to the point where the fragment program returns, and for some reason it ignores the alpha in the returned result. I even tried making the last line of the frag shader “c.a = 0;” and no change.
Does anyone know why the shader hates me?
code:
Shader "Labyrinth/Cone Circle" {
Properties {
_MainTex ("Base (RGBA)", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType"="Transparent"
"Queue" = "Transparent+2"
"IgnoreProjector"="True"
}
ZWrite Off
Blend OneMinusDstColor One
Cull Off
ZTest LEqual
Pass{
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
sampler2D _MainTex;
fixed4 _MainTex_ST;
fixed4 _Color;
struct v2f
{
half4 color : COLOR;
fixed4 pos : SV_POSITION;
fixed2 uv : TEXCOORD0;
};
v2f vert(appdata_full v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color.rgba = v.color.rgba;
return o;
}
fixed4 frag(v2f i) : COLOR
{
i.uv.y -= _Time.x * 5;
fixed4 c = tex2D(_MainTex, i.uv) * i.color;
c.rgb *= _Color.rgb;
c.a *= _Color.a;
return c;
}
ENDCG
}
}
}