#version 410 core uniform float fGlobalTime; // in seconds uniform vec2 v2Resolution; // viewport resolution (in pixels) uniform sampler1D texFFT; // towards 0.0 is bass / lower freq, towards 1.0 is higher / treble freq uniform sampler1D texFFTSmoothed; // this one has longer falloff and less harsh transients uniform sampler2D texBirds; uniform sampler2D texGrass; uniform sampler2D texNormal; uniform sampler2D texPerlin; uniform sampler2D texTiles; uniform sampler2D texZigZag; layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything const float PI = 3.14159265; vec3 background(vec2 p) { vec2 normalizedPosition = p / v2Resolution.y; vec2 offset = vec2(sin(fGlobalTime * .8), cos(fGlobalTime)); vec2 normalizedPosition2 = normalizedPosition - offset; vec2 scaledPosition = normalizedPosition * (sin(fGlobalTime) * .2 + .8); float rotation = sin(fGlobalTime * .7) * 1.3; vec2 rotatedPosition = vec2( cos(rotation) * scaledPosition.x + sin(rotation) * scaledPosition.y, cos(rotation) * scaledPosition.y - sin(rotation) * scaledPosition.x); vec2 uv = rotatedPosition + offset; return texture(texBirds, uv).xyz; } void main(void) { vec3 color = background(gl_FragCoord.xy + vec2(sin(fGlobalTime * .4 + gl_FragCoord.y * .02), cos(fGlobalTime * .6 + gl_FragCoord.x * .006)) * 20.); vec2 circlePos = (vec2(cos(fGlobalTime * .6), sin(fGlobalTime * .5)) * .8 * .5 + .5) * v2Resolution; float circleRad = 200.0; vec2 relCirclePos = gl_FragCoord.xy - circlePos; if (length(relCirclePos) <= circleRad) { color = (background(gl_FragCoord.xy + mix(vec2(0.0), relCirclePos * 4.0, 1.0 - cos(length(relCirclePos) / circleRad) * PI)) + texture(texPerlin, relCirclePos / 400.0).xyz) * vec3(2, .8, .8); } color -= pow(abs(gl_FragCoord.y / v2Resolution.y - .5) * 2.0, 4.0); color = pow(color * (4.2 - texture(texFFT, .2).x * 1500.0), vec3(3.0)); color = color.zyx; // gamma adjust out_color.rgb = pow(clamp(color, 0.0, 1.0), vec3(1 / 2.2)); }