summary refs log tree commit diff stats
path: root/shaders/bloom1.fragment
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/bloom1.fragment')
-rw-r--r--shaders/bloom1.fragment50
1 files changed, 6 insertions, 44 deletions
diff --git a/shaders/bloom1.fragment b/shaders/bloom1.fragment index cfb2799..0a89ea1 100644 --- a/shaders/bloom1.fragment +++ b/shaders/bloom1.fragment
@@ -4,51 +4,13 @@ in vec2 UV;
4 4
5out vec3 color; 5out vec3 color;
6 6
7uniform sampler2D screenTex; 7uniform vec2 offset;
8uniform float iGlobalTime; 8uniform sampler2D inTex;
9uniform vec2 resolution;
10
11float nrand(vec2 n)
12{
13 return fract(sin(dot(n.xy, vec2(19.9898, 78.233))) * 43758.5453);
14}
15
16vec2 rot2d(vec2 p, float a)
17{
18 vec2 sc = vec2(sin(a), cos(a));
19 return vec2(dot(p, vec2(sc.y, -sc.x)), dot(p, sc.xy));
20}
21 9
22void main() 10void main()
23{ 11{
24 const int NUM_TAPS = 12; 12 color = vec3(0.0);
25 float max_siz = 15.0; 13 color += (5.0/16.0) * texture(inTex, UV - offset).rgb;
26 14 color += (6.0/16.0) * texture(inTex, UV).rgb;
27 vec2 fTaps_Poisson[NUM_TAPS]; 15 color += (5.0/16.0) * texture(inTex, UV + offset).rgb;
28 fTaps_Poisson[0] = vec2(-.326, -.406);
29 fTaps_Poisson[1] = vec2(-.840, -.074);
30 fTaps_Poisson[2] = vec2(-.696, .457);
31 fTaps_Poisson[3] = vec2(-.203, .621);
32 fTaps_Poisson[4] = vec2( .962, -.195);
33 fTaps_Poisson[5] = vec2( .473, -.480);
34 fTaps_Poisson[6] = vec2( .519, .767);
35 fTaps_Poisson[7] = vec2( .185, -.893);
36 fTaps_Poisson[8] = vec2( .507, .064);
37 fTaps_Poisson[9] = vec2( .896, .412);
38 fTaps_Poisson[10] = vec2(-.322, -.933);
39 fTaps_Poisson[11] = vec2(-.792, -.598);
40
41 vec4 sum = vec4(0);
42 float rnd = 6.28 * nrand(UV + fract(iGlobalTime));
43 vec4 basis = vec4(rot2d(vec2(1,0), rnd), rot2d(vec2(0,1), rnd));
44 for (int i=0; i<NUM_TAPS; i++)
45 {
46 vec2 ofs = fTaps_Poisson[i];
47 ofs = vec2(dot(ofs, basis.xz), dot(ofs, basis.yw));
48
49 vec2 texcoord = UV + max_siz * ofs / resolution;
50 sum += texture(screenTex, texcoord, -10.0);
51 }
52
53 color = (sum / vec4(NUM_TAPS)).rgb;
54} 16}