-
Notifications
You must be signed in to change notification settings - Fork 5
/
defaultShaders.js
42 lines (30 loc) · 1.02 KB
/
defaultShaders.js
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
export const _fragmentShaderC = `
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_vol;
// main is a reserved function that is going to be called first
void main(void)
{
vec2 normCoord = gl_FragCoord.xy/u_resolution;
float time = u_time/5.0; //slow down time
vec2 uv = -1. + 2. * normCoord;
float r = sin(time + uv.x);
// x is left to right, why we see red moving from right to left think about us as a camera moving around
// sin returns a number from -1 to 1, and colors are from 0 to 1, so it clips to no red half the time
float g = sin(-time + uv.y * 20.); // higher frequency green stripes
float b = mod(uv.x / uv.y,1.0);
// when x is eual to y the colors will be brighter, mod repeats the space
// mod is like a sawtooth function
vec4 color = vec4(r,g,b,1);
gl_FragColor = color;
}
`;
export const _vertexShaderC = `
attribute vec2 aVertexPosition;
void main() {
gl_Position = vec4(aVertexPosition, 0.0, 1.0);
}
`;