2019-01-25 00:10:42 Other

Other

Copy Copied! Full
Shader "RunforLive/KillEffect" { Properties { _MainTex ("texture", 2D) = "white" {} [Header(Effect)] _Color ("color", color) = (1, 1, 1, 1) _TimeOffset ("Animation time offset", Range(0, 1)) = 0 _HeightMul ("Height move multiplier", Range(0, 100)) = 10 } SubShader { Tags { "RenderType"="TransparentCutout" "Queue"="AlphaTest" "IgnoreProjector"="True"} Blend SrcAlpha OneMinusSrcAlpha ZTest Less LOD 200 Pass { Cull Back ZWrite On CGPROGRAM #pragma target 4.0 #pragma vertex vert #pragma fragment frag #pragma multi_compile_fog #include "UnityCG.cginc" sampler2D _MainTex; float4 _MainTex_ST; float _TimeOffset; struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; float2 uv : TEXCOORD0; UNITY_FOG_COORDS(2) }; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); return o; } fixed4 frag(v2f i) : SV_Target { if(_TimeOffset > 0.0000000000000001) discard; fixed4 col = tex2D(_MainTex, i.uv); col.a = 1 - _TimeOffset; UNITY_APPLY_FOG(i.fogCoord, col); return col; } ENDCG } Pass { Cull Off ZWrite Off CGPROGRAM #pragma target 4.0 #pragma vertex vert #pragma geometry geo #pragma fragment frag #pragma multi_compile_fog #include "UnityCG.cginc" sampler2D _MainTex; float4 _MainTex_ST; float4 _Color; float _TimeOffset; float _HeightMul; struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; float3 normal : NORMAL; }; struct v2g { float4 vertex : POSITION; float2 uv : TEXCOORD0; float3 normal : NORMAL; }; struct g2f { float4 vertex : SV_POSITION; float2 uv : TEXCOORD0; UNITY_FOG_COORDS(2) }; float rand(fixed2 p) { return frac(sin(dot(p, fixed2(12.9898,78.233))) * 43758.5453); } v2g vert (appdata v) { v2g o; o.vertex = v.vertex; o.uv = v.uv; o.normal = v.normal; return o; } [maxvertexcount(18)] void geo(triangle v2g v[3], inout TriangleStream<g2f> outs) { g2f o; float3 normal = (v[0].normal+v[1].normal+v[2].normal)/3; float3 n = normalize(v[0].vertex.xyz+v[1].vertex.xyz+v[2].vertex.xyz); float x = n.x*10; float z = 5-n.z*10; [unroll] for(int k = 0; k < 2; k++) { float to = pow(_TimeOffset+0.2, 2) / pow(2-k, 0.5); [unroll] for(int i = 0; i < 3; i++) { o.uv = TRANSFORM_TEX(v[i].uv, _MainTex); o.vertex = UnityObjectToClipPos(v[i].vertex); o.vertex.xyz += ((normal * rand(v[0].uv.xy) * -10 + float3(rand(v[2].uv.xy)*x, -rand(v[1].uv.xy), rand(v[0].uv.xy*k)*z)) / 20) * to + float3(0, rand(normal.xy*k), 0) * -_HeightMul * pow(_TimeOffset+0.1, 4); UNITY_TRANSFER_FOG(o, o.vertex); outs.Append(o); } outs.RestartStrip(); } } fixed4 frag (g2f i) : SV_Target { if(_TimeOffset < 0.0000000000000001 || _TimeOffset > 0.99999999999999999) discard; fixed4 col = _Color; col.a = 1-pow(_TimeOffset, 4); UNITY_APPLY_FOG(i.fogCoord, col); return col; } ENDCG } } }