A typical shader is like this:
struct vin_vct
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f_vct
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
v2f_vct vert_vct(vin_vct v)
{
v2f_vct o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.color;
o.texcoord = v.texcoord;
return o;
}
fixed4 frag_mult(v2f_vct i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
return col;
}
What I'm confused is: vert_vct is called every vertex; frag_mult is called every fragment (pixel in most cases);
So basically frag_mult will run different times with vert_vct, for example, frag mult runs 10 times, and vert_vct runs 3 times for a triangle. Then every time frag_mult runs it will accept a parameter passed by vert_vct, then how to map between frag and vert if the run times are different, how to decide which vert_vct will pass to specified frag_mult?