#version 450 core #ifdef GL_ES precision mediump float; #endif uniform vec2 resolution; uniform float time; uniform float ticks; uniform int program; uniform sampler2D images[8]; layout (binding = 0,rgba32f) uniform image2D backbuffer; uniform float params[4]; out vec4 fragColor; float random (in float x) { return fract(sin(x)*43758.5453123)-0.5; } vec2 st() { return gl_FragCoord.xy/resolution.xy; } ivec2 ist() { return ivec2(gl_FragCoord.xy/resolution.xy*resolution); } vec2 zoom(vec2 st, float amount) { st -= 0.5; st *= amount; st += 0.5; return st; } vec2 translate(vec2 st, vec2 amount) { st -= 0.5; st += amount; st += 0.5; return st; } mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } void main (void) { vec4 img; vec2 coord; if (program == 0) { coord = zoom(st(),0.5-0.5*(1.0-params[0])); img = texture2D(images[0],coord); img -= params[1]*(1.0-texture2D(images[1],st())); } else if (program == 1) { coord = translate(coord,vec2(0.5,0.5)); coord = zoom(coord,2.5); coord = translate(coord,vec2(-0.5,-0.5)); //coord = zoom(st(),0.5); //coord = zoom(coord,2.1*(1.0-0.5*params[0])); //coord = zoom(st(),0.5-0.5*(1.0-params[0])); //coord = zoom(st(),(1.0-1.5*params[2])); //coord = translate(coord,vec2(0,params[0])); img = texture2D(images[0],coord); coord = zoom(st(),0.5-0.5*(1.0-params[0])); vec3 i2 = texture2D(images[2],coord).rgb; //img.rgb = pow((1.0-2.0*i2),img.rgb+0.6); img.rgb = pow(img.rgb,1.0-i2); } else if (program == 2) { coord = zoom(st(),(1.0-1.5*params[2])); img = texture2D(images[3],coord); coord = zoom(st(),0.5*(1.0-0.5*params[0])); coord = translate(coord,vec2(0.2,0.15)); vec3 i2 = texture2D(images[2],coord).rgb; img.rgb = pow((1.0-2.0*i2),params[3]*5*img.rgb); /* coord = zoom(st(),(1.0-1.5*params[0])); img = texture2D(images[3],coord); coord = zoom(st(),0.5*(1.0-0.5*params[2])); coord += 0.5; coord *= rotate2d(params[3]-0.5); coord -= 0.5; vec3 i2 = texture2D(images[2],coord).rgb; img.rgb = pow(img.rgb,5*i2); */ } else if (program == 3) { coord = st() + 0.5; coord -= 0.5; img = texture2D(images[3],coord); coord = zoom(st(),0.5*(1.0-0.5*params[0])); //coord = translate(coord,vec2(0.2,0.15)); //coord = rotate2d(1.0-1.5*params[2])*coord; coord = rotate2d(sin(ticks))*coord; vec3 i2 = texture2D(images[2],coord).rgb; img.rgb = pow((1.0-2.0*i2),params[3]*5*img.rgb); /* */ } else if (program == 4) { coord = zoom(st(),(1.0-1.5*params[0])); coord = rotate2d(ticks)*coord; coord = translate(coord,vec2(0.5,0.5)); img = texture2D(images[3],coord); coord = zoom(st(),0.5*(1.0-0.5*params[2])); coord = translate(coord,vec2(0.2,0.15)); coord = rotate2d(1.0-1.5*params[2])*coord; //coord += 0.5; //coord *= rotate2d(params[3]-0.5); //coord -= 0.5; vec3 i2 = texture2D(images[2],coord).rgb; img.rgb = pow(img.rgb,i2); } else if (program == 5) { coord = zoom(st(),(1.0-1.5*params[0])); coord = rotate2d(ticks)*coord; coord = translate(coord,vec2(0.5,0.5)); img = texture2D(images[2],coord); coord = zoom(st(),0.5*(1.0-0.5*params[2])); //coord = translate(coord,vec2(0.2,0.15)); coord = rotate2d(1.0-1.5*params[2])*coord; //coord += 0.5; //coord *= rotate2d(params[3]-0.5); //coord -= 0.5; vec3 i2 = texture2D(images[3],coord).rgb; img.rgb = pow(img.rgb,5*i2); } imageStore(backbuffer,ist(),img); if (program != 0) { vec4 feedback = imageLoad(backbuffer,ist()); img = mix(feedback,img,0.5); } fragColor = img; /* fragColor = vec4(params[1]); feedback.b += 0.01*cos(time/4.); color.r = max(i.r,feedback.r); */ }