aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/shaders/trtrfr.glsl
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-10-14 02:06:42 +0530
committerAkshay Nair <phenax5@gmail.com>2026-10-14 02:27:24 +0530
commit686b2954a7cf0aae0493b4a974400aed64bbb96f (patch)
tree8ec556b14c4d6eb41634e25bf9a0bac40dd4d4ae /src/main/resources/shaders/trtrfr.glsl
parent49b6b0c9d7de093fc63af376afe5d03f1690995a (diff)
downloadart-playground-openrndr-686b2954a7cf0aae0493b4a974400aed64bbb96f.tar.gz
art-playground-openrndr-686b2954a7cf0aae0493b4a974400aed64bbb96f.zip
Add moth trtrfr
Diffstat (limited to 'src/main/resources/shaders/trtrfr.glsl')
-rw-r--r--src/main/resources/shaders/trtrfr.glsl93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/main/resources/shaders/trtrfr.glsl b/src/main/resources/shaders/trtrfr.glsl
new file mode 100644
index 0000000..080aae0
--- /dev/null
+++ b/src/main/resources/shaders/trtrfr.glsl
@@ -0,0 +1,93 @@
+#version 430
+layout(local_size_x = 8, local_size_y = 8) in;
+precision highp float;
+
+#include <complex>
+#include <sdf>
+#include <utils>
+
+uniform float seconds = 0;
+layout(rgba8) uniform writeonly image2D output_image;
+
+uniform float antialiasing = 0.28;
+uniform bool enable_antialiasing = false;
+
+uniform vec2 offset;
+uniform float scale;
+
+const int MAX_ITERATIONS = 1000;
+const float INF_GAP = 10000.0;
+
+vec3 col_blue1 = srgb(0.33, 0.48, 0.60);
+vec3 col_pink1 = srgb(0.98, 0.27, 0.47);
+vec3 col_pink2 = srgb(0.84, 0.24, 0.33);
+vec3 col_yellow1 = srgb(0.90, 0.69, 0.18);
+vec3 col_violet1 = srgb(0.26, 0.11, 0.52);
+vec3 col_green1 = srgb(0.24, 0.40, 0.33);
+vec3 col_wingpat = srgb(0.12, 0.06, 0.03);
+vec3 col_mothbody = srgb(0.12, 0.06, 0.03);
+vec3 col_bg = vec3(0);
+
+vec3 image(vec2 uv) {
+ vec3 color = col_bg;
+
+ vec2 c = (uv - vec2(0, 0.20)) * 6 / scale + offset;
+ c = vec2(c.y, c.x);
+ vec2 z = vec2(0);
+ vec2 last_z;
+ int iter;
+ float last_dist;
+ for (iter = 0; iter <= MAX_ITERATIONS; iter++) {
+ last_z = z;
+ z = csin(ccos(z)) - ctan(z) + c;
+ last_dist = length(z - last_z);
+ if (last_dist >= INF_GAP) break;
+ }
+ float f = float(iter) / float(MAX_ITERATIONS);
+
+ // Pat
+ vec2 p = (uv - vec2(0, -0.012)) * vec2(23, 72);
+ float buttpat = sin(-abs(p.x) - 5) * sin(abs(p.y)) - sin((abs(p.x) - 6) * p.y);
+ color = mix(color, col_wingpat, (smoothstep(-0.5, 1.0, buttpat)) * step(last_dist, 0.0000003));
+ color = mix(color, col_mothbody, (1 - step(last_dist, 0.0000016)) * step(last_dist, 0.05));
+
+ float gap = 0.504;
+ vec2 eyesp = uv - vec2(gap / 2., 0.093);
+ eyesp.x -= round(eyesp.x / gap) * gap;
+
+ float eyes = sdf_circle(eyesp, 0.007);
+ color = mix(color, mix(col_wingpat, col_bg, 0.22), step(abs(eyes) - 0.003, 0));
+
+ // Floral
+ color = mix(color, srgb(0.0, 0.13, 0.08), (1 - step(last_dist, 0.1)) * (1 - step(last_dist, INF_GAP)));
+ color = mix(color, mix(col_pink1, col_violet1, smoothstep(-0.2, 0.5, f)), step(f, 0.9999));
+ color = mix(color, col_yellow1, step(f, 0.016));
+ color = mix(color, col_violet1, step(f, 0.008));
+ color = mix(color, col_pink2, step(f, 0.005));
+ color = mix(color, col_green1, step(f, 0.003));
+
+ 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);
+ if (gl_GlobalInvocationID.x >= resolution.x || gl_GlobalInvocationID.y >= resolution.y) return;
+
+ 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));
+}