-
Notifications
You must be signed in to change notification settings - Fork 2
/
v002.blur.frag
executable file
·64 lines (52 loc) · 1.99 KB
/
v002.blur.frag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
varying vec2 texcoord0;
varying vec2 texcoord1;
varying vec2 texcoord2;
//varying vec2 texcoord3;
//varying vec2 texcoord4;
//varying vec2 texcoord5;
//varying vec2 texcoord6;
//varying vec2 texcoord7;
//varying vec2 texcoord8;
// define our rectangular texture samplers
uniform sampler2DRect tex0;
/*
// bilinear filtering
#define C0 vec2( 1.0, 0.0 )
#define C1 vec2( 0.0, 1.0 )
#define C2 vec2( 1.0, 1.0 )
#define TX texture2DRect
vec4 bilinearTexture2DRect( const sampler2DRect Sampler, const vec2 Coord )
{
vec2 Fract = fract( Coord );
return mix(mix(TX(Sampler, (Coord)), TX(Sampler, (Coord + C0)),Fract.s), mix(TX(Sampler, (Coord + C1)), TX(Sampler,(Coord + C2)), Fract.s), Fract.t);
}
*/
void main (void)
{
vec4 sample0 = texture2DRect(tex0, texcoord0);
vec4 sample1 = texture2DRect(tex0, texcoord1);
vec4 sample2 = texture2DRect(tex0, texcoord2);
// vec4 sample0 = bilinearTexture2DRect(tex0, texcoord0);
// vec4 sample1 = bilinearTexture2DRect(tex0, texcoord1);
// vec4 sample2 = bilinearTexture2DRect(tex0, texcoord2);
/* vec4 sample3 = texture2DRect(tex0, texcoord3);
vec4 sample4 = texture2DRect(tex0, texcoord4);
vec4 sample5 = texture2DRect(tex0, texcoord5);
vec4 sample6 = texture2DRect(tex0, texcoord6);
vec4 sample7 = texture2DRect(tex0, texcoord7);
vec4 sample8 = texture2DRect(tex0, texcoord8);
*/
// quasi gaussian distro
/* vec4 result = sample0 * .25;
result += (sample4 + sample5) * 0.2;
result += (sample3 + sample6) * 0.1;
result += (sample2 + sample7) * 0.05;
result += (sample1 + sample8) * 0.025;
*/
// gl_FragColor = result;
// gl_FragColor = 0.1752 * sample0 + 0.1658 * (sample5 + sample4) + 0.1403 * (sample3 + sample6) + 0.1063 * (sample1 + sample8);
// straight average
// gl_FragColor = (sample0 + sample1 + sample2 + sample3 + sample4 + sample5 + sample6 + sample7 + sample8) / 9.0;
// gl_FragColor = (sample0 * 0.5) + (sample1 * .25) + (sample2 * .25);
gl_FragColor = (sample0 + sample1 + sample2) / (3.0);
}