Week 3 shaders

screen-shot-2021-02-11-at-6-22-59-pm screen-shot-2021-02-11-at-6-57-31-pm

I made a simple grid of squares that change colour randomly. I imported the shader into P5. The shader also has a layer of a different coloured grid that overlays on top occasionally.

code:

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;

float stipes = 24.072;

float random (vec2 st) {
return fract(sin(dot(st.xy,
vec2(-0.062,stipes + u_time * 0.064)))*
4.409);
}

void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;

st *= 9.280; // Scale the coordinate system
vec2 ipos = floor(st*0.396 + abs(sin(u_time *0.396))); // get the integer coords
vec2 fpos = fract(st *-0.068 + abs(cos(u_time *-0.332))); // get the fractional coords
// Assign a random value based on the integer coord
vec3 color = vec3(random( ipos ), fpos);

gl_FragColor = vec4(color,1.0);
}