-
Notifications
You must be signed in to change notification settings - Fork 3
/
final04_BLURFP.fsh
51 lines (42 loc) · 1.49 KB
/
final04_BLURFP.fsh
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
//
#version 130
uniform sampler2D sampler0;
vec4 TexCoord0 = gl_TexCoord[0];
const float blurSize = 1.0 / 512.0; // I've chosen this size because this will result in that every step will be one pixel wide if the RTScene texture is of size 512x512
void
main (void)
{
vec4 baseColor = texture2D (sampler0, TexCoord0.st);
#ifdef BLUR_FP
vec4 sum = vec4 (0.0);
// blur in y (vertical)
// take nine samples, with the distance blurSize between them
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x - 4.0 * blurSize, TexCoord0.y)) * 0.05;
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x - 3.0 * blurSize, TexCoord0.y)) * 0.09;
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x - 2.0 * blurSize, TexCoord0.y)) * 0.12;
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x - blurSize, TexCoord0.y)) * 0.15;
sum += texture2D (sampler0, vec2 (TexCoord0.x, TexCoord0.y)) * 0.16;
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x + blurSize, TexCoord0.y)) * 0.15;
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x + 2.0 * blurSize, TexCoord0.y)) * 0.12;
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x + 3.0 * blurSize, TexCoord0.y)) * 0.09;
sum +=
texture2D (sampler0,
vec2 (TexCoord0.x + 4.0 * blurSize, TexCoord0.y)) * 0.05;
baseColor = sum;
#endif
gl_FragColor = baseColor;
}