1 Shader "Hidden/SeparableBlur" {
2     Properties {
3         _MainTex (
"Base (RGB)", 2D) = "" {}
4     }
5
6     CGINCLUDE
7     
8     #include
"UnityCG.cginc"
9     
10     
struct v2f {
11         float4 pos : SV_POSITION;
12         float2 uv : TEXCOORD0;
13
14         float4 uv01 : TEXCOORD1;
15         float4 uv23 : TEXCOORD2;
16         float4 uv45 : TEXCOORD3;
17     };
18     
19     float4 offsets;
20     
21     sampler2D _MainTex;
22         
23     v2f vert (appdata_img v) {
24         v2f o;
25         o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
26
27         o.uv.xy = v.texcoord.xy;
28
29         o.uv01 = v.texcoord.xyxy + offsets.xyxy * float4(
1,1, -1,-1);
30         o.uv23 = v.texcoord.xyxy + offsets.xyxy * float4(
1,1, -1,-1) * 2.0;
31         o.uv45 = v.texcoord.xyxy + offsets.xyxy * float4(
1,1, -1,-1) * 3.0;
32
33         
return o;
34     }
35         
36     half4 frag (v2f i) : SV_Target {
37         half4 color = float4 (
0,0,0,0);
38
39         color +=
0.40 * tex2D (_MainTex, i.uv);
40         color +=
0.15 * tex2D (_MainTex, i.uv01.xy);
41         color +=
0.15 * tex2D (_MainTex, i.uv01.zw);
42         color +=
0.10 * tex2D (_MainTex, i.uv23.xy);
43         color +=
0.10 * tex2D (_MainTex, i.uv23.zw);
44         color +=
0.05 * tex2D (_MainTex, i.uv45.xy);
45         color +=
0.05 * tex2D (_MainTex, i.uv45.zw);
46         
47         
return color;
48     }
49
50     ENDCG
51     
52 Subshader {
53  Pass {
54       ZTest Always Cull Off ZWrite Off
55
56       CGPROGRAM
57       #pragma vertex vert
58       #pragma fragment frag
59       ENDCG
60   }
61 }
62
63 Fallback off
64
65     
66 }
// shader


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