summary refs log tree commit diff stats
path: root/shaders/bloom2.fragment
blob: 6723c2c9133818bf46b16aca484b14d33d1f46ea (plain) (blame)
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
#version 330 core

in vec2 UV;

out vec4 color;

uniform sampler2D clearTex;
uniform sampler2D blurTex;
uniform float iGlobalTime;

float nrand(vec2 n)
{
  return fract(sin(dot(n.xy, vec2(19.9898, 78.233))) * 43758.5453);
}

void main()
{
  vec3 mval = vec3(0.0);
  mval += texture(clearTex, UV).rgb / 2.0;
  mval += texture(blurTex, UV).rgb;
  mval = max(vec3(0.0), mval - 0.5);
  mval *= mval;

  float flicker =  0.5 + nrand(vec2(iGlobalTime));
  flicker *= (flicker);
  //flicker = sqrt(flicker);
  //flicker = pow(flicker, 1.0/8.0);
  //mval *= flicker;
  mval *= mix(vec3(0.0), mval, flicker);

  mval += texture(clearTex, UV).rgb;
  mval = clamp(mval, vec3(0.0), vec3(1.0));

  color = vec4(mval, 1.0);
}