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

25
26 struct
v2f {
27     float4 pos : SV_POSITION;
28     float2 uv : TEXCOORD0;
29     float2 uvOrig : TEXCOORD1;
30 };
31
32 v2f vert (appdata_img v)
33 {
34     v2f o;
35     o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
36     float2 uv = v.texcoord.xy - _CenterRadius.xy;
37     o.uv = TRANSFORM_TEX(uv, _MainTex);
//MultiplyUV (UNITY_MATRIX_TEXTURE0, uv);
38     o.uvOrig = uv;
39     
return o;
40 }
41
42 float4 frag (v2f i) : SV_Target
43 {
44     float2 offset = i.uvOrig;
45     
float angle = 1.0 - length(offset / _CenterRadius.zw);
46     angle = max (
0, angle);
47     angle = angle * angle * _Angle;
48     
float cosLength, sinLength;
49     sincos (angle, sinLength, cosLength);
50     
51     float2 uv;
52     uv.x = cosLength * offset[
0] - sinLength * offset[1];
53     uv.y = sinLength * offset[
0] + cosLength * offset[1];
54     uv += _CenterRadius.xy;
55     
56     
return tex2D(_MainTex, uv);
57 }
58 ENDCG
59
60     }
61 }
62
63 Fallback off
64
65 }


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