1 Shader "Hidden/Twirt Effect Shader" {
2 Properties {
3     _MainTex (
"Base (RGB)", 2D) = "white" {}
4 }
5
6 SubShader {
7     Pass {
8         ZTest Always Cull Off ZWrite Off
9                 
10 CGPROGRAM
11 #pragma vertex vert
12 #pragma fragment frag
13 #include
"UnityCG.cginc"
14
15 uniform sampler2D _MainTex;
16 uniform float4 _MainTex_TexelSize;
17 uniform float4 _CenterRadius;
18 uniform float4x4 _RotationMatrix;

19
20 struct
v2f {
21     float4 pos : SV_POSITION;
22     float2 uv : TEXCOORD0;
23 };
24
25 v2f vert( appdata_img v )
26 {
27     v2f o;
28     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
29     o.uv = v.texcoord - _CenterRadius.xy;
30     
return o;
31 }
32
33 float4 frag (v2f i) : SV_Target
34 {
35     float2 offset = i.uv;
36     float2 distortedOffset = MultiplyUV (_RotationMatrix, offset.xy);
37     float2 tmp = offset / _CenterRadius.zw;
38     
float t = min (1, length(tmp));
39     
40     offset = lerp (distortedOffset, offset, t);
41     offset += _CenterRadius.xy;
42     
43     
return tex2D(_MainTex, offset);
44 }
45 ENDCG
46
47     }
48 }
49
50 Fallback off
51
52 }


Gõ tìm kiếm nhanh...