I'm currently trying to learn how to write shaders, so I'm getting my feet wet with Unity's Shaderlab format. One of the first things I tried was to write a surface shader that supports vertex colors being assigned from code. Unfortunately, whenever I try to apply the shader to my object, it just renders the object completely transparent.
Shader "Custom/SVCA" {
Properties {
_Color ("Color", Color) = (1, 1, 1, 1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" { }
}
SubShader {
Tags {
"Queue"="Transparent"
"RenderType"="Transparent"
}
CGPROGRAM
#pragma surface surf Lambert alpha
struct Input {
float2 uv_MainTex;
float4 color;
};
sampler2D _MainTex;
fixed4 _Color;
void surf(Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb * IN.color.rgb * _Color.rgb;
o.Alpha = tex2D(_MainTex, IN.uv_MainTex).a * IN.color.a * _Color.a;
o.Specular = 0.2;
o.Gloss = 1.0;
}
ENDCG
}
FallBack "Diffuse", 1
}
What is causing this issue, and how can I fix it?