-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshader.vert
More file actions
49 lines (37 loc) · 1.35 KB
/
shader.vert
File metadata and controls
49 lines (37 loc) · 1.35 KB
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
const fragShaderSrc = `
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 vTexCoord;
uniform sampler2D u_tex0;
uniform float u_time;
float random(vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);
}
void main() {
float distortion_s = 0.02;
float glow_s = 0.2;
float static_s = 0.15;
float scanline_s = 0.1;
float fine_noise_s = 0.05;
if (vTexCoord.x < 0.0 || vTexCoord.x > 1.0 || vTexCoord.y < 0.0 || vTexCoord.y > 1.0) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
return;
}
float horiz_wobble = sin(vTexCoord.y * 10.0 + u_time * 1.5) * distortion_s;
vec2 distorted_uv = vTexCoord + vec2(horiz_wobble, 0.0);
vec3 source_color = texture2D(u_tex0, distorted_uv).rgb;
float luminance = dot(source_color, vec3(0.299, 0.587, 0.114));
vec3 color = vec3(luminance);
color = pow(color, vec3(1.4));
float scanline = sin(vTexCoord.y * 480.0 * 1.5) * scanline_s;
color -= scanline;
float tracking_pos = fract(u_time * 0.1);
float tracking_bar = smoothstep(0.4, 0.0, abs(vTexCoord.y - tracking_pos) * 5.0);
color -= tracking_bar * static_s * random(vTexCoord + u_time);
color += (random(vTexCoord) - 0.5) * fine_noise_s;
float glow = pow(luminance, 4.0) * glow_s;
color += glow;
gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);
}
`;