forked from patriciogonzalezvivo/lygia_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_edge2D.frag
37 lines (27 loc) · 915 Bytes
/
filter_edge2D.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
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D u_tex0;
uniform vec2 u_tex0Resolution;
#include "lygia/sample/clamp2edge.glsl"
#define EDGE_SAMPLER_FNC(TEX, UV) sampleClamp2edge(TEX, UV).r
#include "lygia/filter/edge.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(0.1, ix * 0.5);
if (st.y < 0.5)
color += edgePrewitt(u_tex0, st, pixel * radius);
else
color += edgeSobel(u_tex0, st, pixel * radius);
color -= step(st.y, 0.05) * 0.5;
color = clamp(color, vec3(0.), vec3(1.));
color += digits(st - vec2(ix/5.0 + 0.01, 0.01), radius);
color -= step(.98, fract(st.x * 5.0));
gl_FragColor = vec4(color,1.0);
}