1struct outtype {float4 color : COLOR;};
2
3uniform float4 srctexsize;
4
5outtype blur1(float2 uv : TEXCOORD0, uniform sampler2D sampler_blur : TEX0)
6{
7float2 uv2 = uv.xy + srctexsize.zw*float2(1,1);
8
9float d=.00175;
10
11float3 val =  tex2D(sampler_blur, float2(uv.x-d, uv.y)).xyz;
12val += tex2D(sampler_blur, float2(uv.x+d, uv.y)).xyz;
13val += tex2D(sampler_blur, float2(uv.x, uv.y + d)).xyz;
14val += tex2D(sampler_blur, float2(uv.x, uv.y - d)).xyz;
15
16float3 val2 =  tex2D(sampler_blur, float2(uv.x-d, uv.y -d)).xyz;
17val += tex2D(sampler_blur, float2(uv.x-d, uv.y +d)).xyz;
18val += tex2D(sampler_blur, float2(uv.x+d, uv.y + d)).xyz;
19val += tex2D(sampler_blur, float2(uv.x +d, uv.y - d)).xyz;
20
21outtype OUT;
22val *= 0.65;
23val2 *= 0.35;
24
25OUT.color.xyz = val* 0.25 + val2 * 0.25;
26OUT.color.w = 1;
27return OUT;
28}
29
30outtype blur2(float2 uv : TEXCOORD0, uniform sampler2D sampler_blur : TEX0)
31{
32float2 uv2 = uv.xy + srctexsize.zw*float2(1,0);
33
34float d = srctexsize.z;
35d=.0015;
36
37float3 val =  tex2D(sampler_blur, float2(uv.x-d, uv.y)).xyz;
38val += tex2D(sampler_blur, float2(uv.x+d, uv.y)).xyz;
39val += tex2D(sampler_blur, float2(uv.x, uv.y + d)).xyz;
40val += tex2D(sampler_blur, float2(uv.x, uv.y - d)).xyz;
41
42val *= 0.25;
43
44float t = min( min(uv.x, uv.y), 1-max(uv.x,uv.y) );
45t = sqrt(t);
46
47float minimum = 0.5;
48float variance = 0.5;
49float size = 50;
50
51t = minimum + variance*saturate(t*size);
52t = 1;
53val.xyz *= t;
54
55outtype OUT;
56OUT.color.xyz = val;
57OUT.color.w = 1;
58return OUT;
59}
60
61outtype blurHoriz(float2 uv : TEXCOORD0, uniform sampler2D sampler_blur : TEX0)
62{
63
64	 // LONG HORIZ. PASS 1:
65	    const float w[8] = { 4.0, 3.8, 3.5, 2.9, 1.9, 1.2, 0.7, 0.3 };
66	    const float w1 = w[0] + w[1];
67	    const float w2 = w[2] + w[3];
68	    const float w3 = w[4] + w[5];
69	    const float w4 = w[6] + w[7];
70	    const float d1 = 0 + 2*w[1]/w1;
71	    const float d2 = 2 + 2*w[3]/w2;
72	    const float d3 = 4 + 2*w[5]/w3;
73	    const float d4 = 6 + 2*w[7]/w4;
74	    const float w_div = 0.5/(w1+w2+w3+w4);
75
76float  fscale = 1;
77float  fbias = 0;
78
79
80	    // note: if you just take one sample at exactly uv.xy, you get an avg of 4 pixels.
81	    //float2 uv2 = uv.xy;// + srctexsize.zw*float2(0.5,0.5);
82	    float2 uv2 = uv.xy + srctexsize.zw*float2(1,1);     // + moves blur UP, LEFT by 1-pixel increments
83
84	    float3 blur =
85	            ( tex2D( sampler_blur, uv2 + float2( d1*srctexsize.z,0) ).xyz
86	            + tex2D( sampler_blur, uv2 + float2(-d1*srctexsize.z,0) ).xyz)*w1 +
87	            ( tex2D( sampler_blur, uv2 + float2( d2*srctexsize.z,0) ).xyz
88	            + tex2D( sampler_blur, uv2 + float2(-d2*srctexsize.z,0) ).xyz)*w2 +
89	            ( tex2D( sampler_blur, uv2 + float2( d3*srctexsize.z,0) ).xyz
90	            + tex2D( sampler_blur, uv2 + float2(-d3*srctexsize.z,0) ).xyz)*w3 +
91	            ( tex2D( sampler_blur, uv2 + float2( d4*srctexsize.z,0) ).xyz
92	            + tex2D( sampler_blur, uv2 + float2(-d4*srctexsize.z,0) ).xyz)*w4
93	            ;
94	    blur.xyz *= w_div;
95
96	    blur.xyz = blur.xyz*fscale + fbias;
97
98	    outtype OUT;
99	    OUT.color.xyz = blur;
100	    OUT.color.w   = 1;
101
102return OUT;
103}
104
105outtype blurVert(float2 uv : TEXCOORD0, uniform sampler2D sampler_blur : TEX0)
106{
107	 //SHORT VERTICAL PASS 2:
108
109
110	const float w[8] = { 4.0, 3.8, 3.5, 2.9, 1.9, 1.2, 0.7, 0.3 };
111
112	 const float w1 = w[0]+w[1] + w[2]+w[3];
113		    const float w2 = w[4]+w[5] + w[6]+w[7];
114		    const float d1 = 0 + 2*((w[2]+w[3])/w1);
115		    const float d2 = 2 + 2*((w[6]+w[7])/w2);
116		  const float w_div = 1.0/((w1+w2)*2);
117
118
119
120	    // note: if you just take one sample at exactly uv.xy, you get an avg of 4 pixels.
121	    //float2 uv2 = uv.xy;// + srctexsize.zw*float2(-0.5,-0.5);
122	    float2 uv2 = uv.xy + srctexsize.zw*float2(1,0);     // + moves blur UP, LEFT by TWO-pixel increments! (since texture is 1/2 the size of blur1_ps)
123
124	    float3 blur =
125	            ( tex2D( sampler_blur, uv2 + float2(0, d1*srctexsize.w) ).xyz
126	            + tex2D( sampler_blur, uv2 + float2(0,-d1*srctexsize.w) ).xyz)*w1 +
127	            ( tex2D( sampler_blur, uv2 + float2(0, d2*srctexsize.w) ).xyz
128	            + tex2D( sampler_blur, uv2 + float2(0,-d2*srctexsize.w) ).xyz)*w2
129	            ;
130	    blur.xyz *= w_div;
131
132	    // tone it down at the edges:  (only happens on 1st X pass!)
133	    float t = min( min(uv.x, uv.y), 1-max(uv.x,uv.y) );
134
135	    float minimum = 0.5;
136	    float variance = 0.5;
137	    float size = 50;
138
139
140	    blur.xyz *= t;
141
142	    t = sqrt(t);
143	    t = minimum + variance*saturate(t*size);
144	    t=1;
145	    blur.xyz *= t;
146
147outtype OUT;
148OUT.color.xyz = blur;
149OUT.color.w = 1;
150return OUT;
151}
152