码迷,mamicode.com
首页 > 编程语言 > 详细

Unity Shader Billboard

时间:2015-06-01 14:39:37      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

记录来源于ShaderLab开发实战详解

Shader "Tut/Project/Billboard_1" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
pass{
Cull Off
ZTest Always
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos:SV_POSITION;
float2 texc:TEXCOORD0;
};
v2f vert(appdata_base v)
{
v2f o;
float4 ori=mul(UNITY_MATRIX_MV,float4(0,0,0,1));
float4 vt=v.vertex;
vt.y=vt.z;//这个平面是沿xz平面 展开的
vt.z=0;//所以只关心其平面上的信息

//通过加上Object Space的原点在ViewSpace的信息,保持其透视大小
vt.xyz+=ori.xyz;//result is vt.z==ori.z ,so the distance to camera keeped ,and screen size keeped
o.pos=mul(UNITY_MATRIX_P,vt);

o.texc=v.texcoord;
return o;
}
float4 frag(v2f i):COLOR
{
return tex2D(_MainTex,i.texc);
}
ENDCG
}//endpass
}
}

Unity Shader Billboard

标签:

原文地址:http://www.cnblogs.com/j349900963/p/4543837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!