#version 150 precision highp float; precision highp int; //Ethan Alexander Shulman 2022 "Alien Kingdom Fractal" May 16, 2022 in vec3 in_Position; out vec4 uv; out float time; layout(std140) uniform ShaderviewBlock { vec4 mouse; float screenX,screenY; int frame,framerate; }; #define AA_SAMPLES 100 #define PI 3.141592653589793 mat2 r2d(float a) { float c = cos(a), s = sin(a); return mat2(c,s,-s,c); } //r2 hash http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ vec2 quasiRandom(float n) { #define R2V 1.32471795724474602596 return fract(.5+n*(1./vec2(R2V,R2V*R2V))); } float line(vec2 p, vec2 a, vec2 b) { vec2 pa = p-a, ba = b-a; return length(pa-ba*clamp(dot(pa,ba)/dot(ba,ba),0.,1.)); } vec3 hue(float h) { return clamp(abs(mod(h*6.+vec3(0.,4.,2.),6.)-3.)-1.,0.,1.); } uniform sampler2D Buffer0; void vert() { time = float(frame)/float(framerate*AA_SAMPLES);//end = 147.5 uv = vec4((in_Position.xy*vec2(screenX/screenY,1)+(quasiRandom(float(frame%AA_SAMPLES))-.5)*2./screenY)*1.1*pow(.98,max(0.,time-50.))+vec2(0,time*-mix(.01,.003,clamp((time-40.)/30.,0.,1.))), (in_Position.xy*.5+.5)*vec2(screenX,screenY)); gl_Position = vec4(in_Position,1); } void frag() { vec2 p = uv.xy, a = p; int i; for (i = 0; i < 60 && length(p) < 1e4; i++) { float l = length(p); if (l != 0.) l = time*.01/l; p = p*mat2(p.y,p.x,-p.x,p.y)+a*l; } float fi = float(i); vec4 sum = texelFetch(Buffer0,ivec2(uv.zw),0); if (frame%AA_SAMPLES == 0) sum = vec4(0); sum += vec4(vec3(max(0.,sin(fi*PI*2./60.+time))), 1.); gl_FragColor = sum; }