Hello!
I’m trying to make a lit shader where the vertex colour adds to the emissive property: ie an illuminated shader, which can have self-illumination based on vertex colour.
I’m a bit of a noob with shader programming, so I would appreciate some hints. So far I’ve been trying to adapt http://wiki.unity3d.com/index.php/VertexColor to no avail.
Thank you for your help!
Don’t worry - solved it. Here’s what I learnt:
Properties {
//I didn't have a property name "_Color" in case it interfered...
....
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf BlinnPhong
sampler2D _MainTex;
half _Shininess;
half _Gloss;
struct Input {
....
float4 color : COLOR; //<--- this gets the vertex colour data
....
};
void surf (Input IN, inout SurfaceOutput o) {
....
o.Emission = IN.color.rgb - IN.color.a; //<-- I used the colour RGB - the Alpha, so I could control how much each vertex emits.
....
}
ENDCG
}