aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/shaders
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-10-06 10:31:35 +0530
committerAkshay Nair <phenax5@gmail.com>2026-10-06 10:31:35 +0530
commit86aef485479099cb86d7bd92a7f7abde2971dd61 (patch)
tree96a3e900217ce3a91b2052d1f5e029b5e749675b /src/main/resources/shaders
parentbd2e1ec3aba1368671f7d120f1a9183c5d29d95f (diff)
downloadart-playground-openrndr-86aef485479099cb86d7bd92a7f7abde2971dd61.tar.gz
art-playground-openrndr-86aef485479099cb86d7bd92a7f7abde2971dd61.zip
Mitosis redux
Diffstat (limited to 'src/main/resources/shaders')
-rw-r--r--src/main/resources/shaders/mitosis.glsl60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/resources/shaders/mitosis.glsl b/src/main/resources/shaders/mitosis.glsl
new file mode 100644
index 0000000..7d0d373
--- /dev/null
+++ b/src/main/resources/shaders/mitosis.glsl
@@ -0,0 +1,60 @@
+#version 430
+layout(local_size_x = 1, local_size_y = 1) in;
+
+#include <utils>
+
+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));
+}