#version 430 layout(local_size_x = 1, local_size_y = 1) in; #include uniform float seconds = 0; layout(rgba8) uniform readonly image2D noise_texture; layout(rgba8) uniform writeonly image2D output_image; uniform float antialiasing = 0.28; uniform bool enable_antialiasing = true; float sample_noise(in vec2 p) { vec4 noise = imageLoad(noise_texture, ivec2(p * imageSize(noise_texture))); return noise.x; } vec3 image(vec2 uv) { const vec3 bg_color = srgb(0.16, 0.16, 0.21); const vec3 color1 = srgb(0.09, 0.57, 0.6); const vec3 color2 = srgb(0.31, 0.23, 0.64); const vec3 color3 = srgb(0.82, 0.06, 0.22); float duration = 10.0; float t = mod(seconds, duration) - duration / 2; t *= 0.5; vec3 color = bg_color; vec2 p = uv * 11.6; float v = 1 - (sin(p.x * p.x) - sin(p.y * p.y) - sin(t * p.x * p.y)); color = mix(color, color1, step(v, 1.4)); color = mix(color, color2, step(v, 1.1)); color = mix(color, color3, step(v, 0.84)); color = mix(color, color2, step(v, 0.6)); color = mix(color, color1, step(v, 0.3)); color = mix(color, bg_color, step(v, 0.1)); return color; } vec3 antialiased_image(vec2 uv) { vec2 resolution = vec2(imageSize(output_image).xy); float s = antialiasing / max(resolution.x, resolution.y); vec3 sum = vec3(0); int count = 0; for (int i = -2; i < 2; i++) for (int j = -2; j < 2; j++, count++) sum += image(uv + vec2(i, j) * s); return sum / count; } void main() { vec2 resolution = vec2(imageSize(output_image).xy); float aspect_ratio = resolution.y / resolution.x; vec2 uv = (gl_GlobalInvocationID.xy - resolution / 2.) * vec2(1.0, aspect_ratio) / resolution; vec3 color = enable_antialiasing ? antialiased_image(uv) : image(uv); imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(color, 1)); }