废话不多说,写了个shade控制的billboard
v2f vert (appdata_full V)
{
v2f o = (v2f)0;
float4x4 reverse = float4x4(-1.0,0.0,0.0,0.0,
0.0,0.0,-1.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,0.0,1.0);
float4x4 matAll,matAllNoView;
matAll = mul(UNITY_MATRIX_MV,reverse);
matAllNoView = mul(_Object2World,reverse);
float3 centerPos = float3(matAll[0][3],matAll[1][3],matAll[2][3]);
float3 originalPos = V.vertex;
float3 deta = mul(matAllNoView,float4(originalPos,0.0));
o.pos = float4(centerPos + deta,1.0);
o.pos = mul(UNITY_MATRIX_P,o.pos);
o.packUV.xy = V.texcoord.xy;
return o;
}
float4 frag (v2f IN) : COLOR
{
float4 tex = tex2D(_MainTex, IN.packUV.xy);
float4 c=0;
c.rgb= tex.rgb*_Color.rgb;
c.a = tex.a*_Color.a;
return c;
}