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.
50 lines
1.2 KiB
50 lines
1.2 KiB
uniform vec2 u_resolution;
|
|
uniform vec2 u_mouse;
|
|
uniform float u_time;
|
|
uniform sampler2D texture;
|
|
|
|
#define PI 3.14159265358979323846
|
|
|
|
vec2 rotate2D(vec2 st, float angle, float view_at=0.5, float origin=0.5) {
|
|
st -= view_at;
|
|
st = mat2(cos(angle), -sin(angle),
|
|
sin(angle), cos(angle)) * st;
|
|
st += origin;
|
|
return st;
|
|
}
|
|
|
|
float box(vec2 st, vec2 size, float smoothEdges) {
|
|
size = vec2(0.5) - size * 0.5;
|
|
vec2 aa = vec2(smoothEdges * 0.5);
|
|
vec2 uv = smoothstep(size, size + aa, st);
|
|
uv *= smoothstep(size, size+aa, vec2(1.0) - st);
|
|
return uv.x * uv.y;
|
|
}
|
|
|
|
vec2 tile(vec2 st, float zoom) {
|
|
st *= zoom;
|
|
return fract(st);
|
|
}
|
|
|
|
float circle(vec2 st, float radius) {
|
|
vec2 l = st - vec2(0.5);
|
|
return 1.0 - smoothstep(radius - (radius * 0.01),
|
|
radius+(radius * 0.01),
|
|
dot(l,l) * 4.0);
|
|
}
|
|
|
|
void main() {
|
|
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
|
|
|
|
vec2 st = gl_FragCoord.xy/u_resolution;
|
|
vec3 color = vec3(0.0);
|
|
vec2 mouse_at = smoothstep(0.1, 0.9, u_mouse/u_resolution);
|
|
|
|
st = tile(st, 4.0);
|
|
|
|
st = rotate2D(st, PI * sin(u_time) / 4, 0.5, mouse_at);
|
|
|
|
color = vec3(box(st, vec2(0.7), 0.01));
|
|
|
|
gl_FragColor = gl_Color * vec4(color, 0.5) * pixel;
|
|
}
|
|
|