forked from patriciogonzalezvivo/lygia_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_noiseBlur2D.frag
39 lines (28 loc) · 987 Bytes
/
filter_noiseBlur2D.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
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D u_tex0;
uniform vec2 u_tex0Resolution;
uniform sampler2D u_noise;
uniform vec2 u_noiseResolution;
uniform vec2 u_resolution;
uniform float u_time;
// #define NOISEBLUR_SECS u_time
// #define NOISEBLUR_GAUSSIAN_K 2.0
// #define BLUENOISE_TEXTURE u_noise
#define BLUENOISE_TEXTURE_RESOLUTION u_noiseResolution
#include "lygia/sample/clamp2edge.glsl"
#define NOISEBLUR_SAMPLER_FNC(TEX, UV) sampleClamp2edge(TEX, UV)
#include "lygia/filter/noiseBlur.glsl"
#include "lygia/draw/digits.glsl"
void main (void) {
vec3 color = vec3(0.0);
vec2 pixel = 1.0/u_resolution;
vec2 st = gl_FragCoord.xy * pixel;
float ix = floor(st.x * 5.0);
float radius = max(1.0, ix * 4.0);
color += noiseBlur(u_tex0, st, pixel, radius).rgb;
color += digits(st - vec2(ix/5.0 + 0.01, 0.01), radius, 0.0);
color -= step(.99, fract(st.x * 5.0));
gl_FragColor = vec4(color,1.0);
}