-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathshaders.mjs
More file actions
47 lines (35 loc) · 960 Bytes
/
shaders.mjs
File metadata and controls
47 lines (35 loc) · 960 Bytes
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
// for syntax highlighting (glsl-literal extension)
const glsl = x => x;
export const vert = glsl`
precision highp float;
attribute vec2 position;
attribute float direction;
uniform float time;
uniform float width;
uniform float height;
uniform sampler2D image;
varying vec4 vTexColor;
const float PI = 3.1415926535;
vec4 invert(vec4 color) {
return vec4(1.0 - color.x, 1.0 - color.y, 1.0 - color.z, 1.0);
}
vec4 shuffleRB(vec4 color) {
return vec4(color.z, color.y, color.x, 1.0);
}
void main() {
vec2 randomVector = vec2(cos(direction * 2.0 * PI), sin(direction * 2.0 * PI)) * sin(time * .1) * .05;
vec2 texCoords = (1.0 - position) * .5 + randomVector;
vTexColor = shuffleRB(texture2D(image, texCoords));
gl_Position = vec4(position, 0.0, 1.0);
}
`;
export const frag = glsl`
precision highp float;
uniform float width;
uniform float height;
uniform float time;
varying vec4 vTexColor;
void main() {
gl_FragColor = vTexColor;
}
`;