-
Notifications
You must be signed in to change notification settings - Fork 130
/
particlesblur.frag
52 lines (39 loc) · 1.98 KB
/
particlesblur.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
#version 330
in INTERFACE {
vec2 uv;
} In ;
uniform sampler2D screenTexture;
uniform vec2 inverseScreenSize;
out vec3 fragColor;
void main(){
const float attenuationFactor = 0.99;
// We have to unroll the box blur loop manually.
// 5x5 box blur, taking every other pixel.
vec3 color = textureOffset(screenTexture, In.uv, 2*ivec2(-2,-2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-2,-1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-2,0)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-2,1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-2,2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-1,-2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-1,-1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-1,0)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-1,1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(-1,2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(0,-2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(0,-1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(0,0)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(0,1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(0,2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(1,-2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(1,-1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(1,0)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(1,1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(1,2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(2,-2)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(2,-1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(2,0)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(2,1)).rgb;
color += textureOffset(screenTexture, In.uv, 2*ivec2(2,2)).rgb;
// Include decay for fade out.
fragColor = color * attenuationFactor / 25.0;
}