旗帜飘扬的Shader
2017-11-22 本文已影响91人
_Arturia
利用顶点变化
Shader "A/B"
{
Properties{
_MainTex ("tu" ,2D) = "white" {}
}
SubShader{
Tags{"RenderType"="Opaque"}
LOD 100
blend SrcAlpha OneMinusSrcAlpha
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f{
fixed4 mVert:POSITION;
fixed4 mTex:TEXCOORD0;
};
sampler2D _MainTex;
float f1;
float f2;
float f3;
v2f vert(appdata_base v):POSITION{
v2f o;
o.mTex=v.texcoord;
v.texcoord.x/=5;
f1 += _Time.y;
f2 = f1 % 5;
f3 = floor(f1/5);
if(f2<1)
v.texcoord.x += f3 * 0.2 + f2/5;
else
v.texcoord.x += (f3+1) * 0.2;
if (v.vertex.x < 4)
v.vertex.y += (sin(f1 * 8 + v.vertex.x) * 2 + sin(f1 * 4 + v.vertex.z)) / 4;
o.mVert= UnityObjectToClipPos(v.vertex);
o.mTex=v.texcoord;
return o;
}
fixed4 frag (v2f aa):COLOR{
return tex2D(_MainTex,aa.mTex);
}
ENDCG
}
}
}