#version 330 core
out vec4 FragColor;
uniform vec3 iResolution;
uniform float iTime;
uniform float uAlpha;

// hypno shader converted

float random(vec2 uv) {
    return fract(sin(dot(uv.xy, vec2(12.9898, 78.233))) * 43758.5453123);
}

float noise(in vec2 p) {
    vec2 i = floor(p);
    vec2 f = fract(p);
    vec2 u = f * f * (3.0 - 2.0 * f);
    return mix(mix(random(i + vec2(0.0, 0.0)), random(i + vec2(1.0, 0.0)), u.x),
               mix(random(i + vec2(0.0, 1.0)), random(i + vec2(1.0, 1.0)), u.x), u.y);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = fragCoord / iResolution.xy;
    uv -= 0.5;
    uv.x *= iResolution.x / iResolution.y;
    
    float dist = length(uv);
    float angle = atan(uv.y, uv.x);

    float spiral = sin(pow(dist, 0.3) * 50.0 - angle * 3.0 - iTime * 10.0 + noise(uv * 3.0) * 2.0);
    
    float pattern = smoothstep(0.3, 0.7, spiral);

    vec3 color = mix(vec3(1.0), vec3(0.0), pattern);
    
    fragColor = vec4(color, 1.0);
}

void main() { mainImage(FragColor, gl_FragCoord.xy); FragColor.a *= uAlpha; }
