Ref:custom Data Computed per-vertex:http://docs.unity3d.com/manual/sl-surfaceshaderexamples.html
Shader "Custom/mystandard_vertexcolor" {
Properties {
_color ("Color", color) = (1,1,1,1)
_maintex ("Albedo (RGB)", 2D) = "White" {}
_glossiness ("Smoothness", Range (0,1)) = 0.5
_metallic ("Metallic", Range (0,1)) = 0.0
}
Subshader {
Tags {"Rendertype" = "Transparent" "Queue" = "Transparent"}
LOD 200
Cgprogram
Physically based standard lighting model, and enable shadows on all light types
#pragma surface surf standard fullforwardshadows Alpha:fade Vertex:vert
Use Shader Model 3.0 target, to get nicer looking lighting
#pragma target 3.0
Sampler2d _maintex;
struct Input {
FLOAT2 Uv_maintex;
Fixed4 My_vertcolor;
};
Half _glossiness;
Half _metallic;
Fixed4 _color;
void Vert (InOut appdata_full V, out Input o) {
Unity_initialize_output (input,o);//ref:http://forum.unity3d.com/threads/what-does-unity_initialize_output-do.186109/
O.my_vertcolor=v.color;
}
void Surf (Input in, InOut surfaceoutputstandard o) {
Albedo comes from a texture tinted by color
Fixed4 C = tex2d (_maintex, In.uv_maintex) * _COLOR*IN.MY_VERTCOLOR;
O.albedo = C.rgb;
Metallic and smoothness come from slider variables
O.metallic = _metallic;
o.smoothness = _glossiness;
O.alpha = C.A;
}
Endcg
}
FallBack "Diffuse"
}
Unity, accessing vertex colors in surface shader