用struct结构体来整合数据进行输入和输出:
subshader{
pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include “unitycg.cginc”//其中有一些数据可直接使用;
struct v2f
{
float4 pos:POSITION;
fixed4 col:COLOR;
};
v2f vert(appdata_base v){
v2f o;
o.pos=mul(UNITY_MATRIX_MVP,v.vertex);
o.col=fixed4(1,0,0,1);
}
fixed4 frag(v2f IN):COLOR{
return IN.col;
}
ENDCG
}
}