A weird game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
turings-tarpit/assets/shaders/matscalerot.frag

49 lines
913 B

uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
#define PI 3.14159265359
mat2 scale(vec2 scale) {
return mat2(scale.x, 0.0, 0.0, scale.y);
}
float box(in vec2 st, in vec2 size) {
size = vec2(0.5) - size * 0.5;
vec2 uv = smoothstep(size,
size + vec2(0.001),
st);
uv *= smoothstep(size,
size+vec2(0.001),
vec2(1.0) - st);
return uv.x * uv.y;
}
float cross(in vec2 st, float size) {
return box(st, vec2(size, size / 4.0)) +
box(st, vec2(size / 4.0, size));
}
mat2 rotate2d(float angle) {
return mat2(cos(angle), -sin(angle),
sin(angle), cos(angle));
}
void main() {
vec2 st = gl_FragCoord.xy / u_resolution.xy;
vec3 color = vec3(0.0);
st -= vec2(0.5);
st = scale(vec2(sin(u_time) + 1.0)) * st;
st = rotate2d(sin(u_time) * PI) * st;
st += vec2(0.5);
color += vec3(cross(st, 0.4));
gl_FragColor = vec4(color, 1.0);
}