I have the following mobile shader I wrote that renders objects with specular highlight and using the color from the mesh’s vertex color (this is a requirement). I can also apply the shader Color property as a tint. I have all of these working.
However, I also need to apply the Alpha from the Color Property to fade the object in and out but it’s not working.
Can someone help me out?
Thanks in advance.
Shader "Custom/MySpecularVertex" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
}
SubShader {
Tags {
"RenderType" = "Transparent"
"Queue" = "Transparent"
}
LOD 250
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
//#pragma surface surf Standard fullforwardshadows
#pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap noforwardadd halfasview
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten)
{
fixed diff = max (0, dot (s.Normal, lightDir));
fixed nh = max (0, dot (s.Normal, halfDir));
fixed spec = pow (nh, s.Specular*128) * s.Gloss;
fixed4 c;
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * (atten*2);
c.a = 0.0;
return c;
}
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float4 vcolor : COLOR;
};
half _Shininess;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
//o.Albedo = c.rgb * IN.vcolor;
o.Albedo = c.rgb * IN.vcolor;
o.Gloss = c.a;
o.Alpha = _Color.a;
o.Specular = _Shininess;
}
ENDCG
}
FallBack "Mobile/VertexLit"
}