1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| Shader "Example/VFClip" { Properties { _MainTex("Base(RGB)",2D) = "white"{} _Color("MainColor(RGB)",Color) = (1,1,1,1) _Speed("Speed(1-100)",Range(1,100)) = 10 _Sum("Sum(1-100)",Range(1,100)) = 20 _Space("Space(0.1-5)",Range(0.1,5)) = 1 _Width("Width(0.1-1)",Range(0.1,1))=0.5 } SubShader { Blend One One AlphaTest Greater 0.5 Cull off Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" float4 _Color; float _Speed; float _Sum; float _Space; float _Width; sampler2D _MainTex; float4 _MainTex_ST; struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 scrPos; } ; v2f vert (appdata_base v) { v2f o; o.pos = mul(UNITY_MATRIX_MVP,v.vertex); o.uv = TRANSFORM_TEX(v.texcoord,_MainTex); o.scrPos = v.vertex; return o; } float4 frag (v2f i) : COLOR { float2 wcoord = (i.scrPos.yz/i.scrPos.w); float4 outp; float l = Time*Speed; if (abs(fmod(Sum*wcoord.x-l,Space))<_Width) { float4 texCol = tex2D(_MainTex,i.uv); outp = _Color*texCol; } else { outp = (0,0,0,0); } return outp; } ENDCG } } FallBack "Diffuse" }
|