unity billboard

废话不多说,写了个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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值