From 686b2954a7cf0aae0493b4a974400aed64bbb96f Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 14 Oct 2026 02:06:42 +0530 Subject: Add moth trtrfr --- src/main/resources/shaders/newton.glsl | 42 ++-------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) (limited to 'src/main/resources/shaders/newton.glsl') diff --git a/src/main/resources/shaders/newton.glsl b/src/main/resources/shaders/newton.glsl index e53b153..a0bcc10 100644 --- a/src/main/resources/shaders/newton.glsl +++ b/src/main/resources/shaders/newton.glsl @@ -2,6 +2,7 @@ layout(local_size_x = 1, local_size_y = 1) in; #include +#include #define MAX_ITERATIONS 200 @@ -9,45 +10,6 @@ const float antialiasing = 0.28; uniform float seconds = 0; layout(rgba8) uniform writeonly image2D output_image; -float fabs(float a) { - return a > 0. ? a : -a; -} - -float cosh(float val) { - float tmp = exp(val); - float cosH = (tmp + 1.0 / tmp) / 2.0; - return cosH; -} - -float sinh(float val) { - float tmp = exp(val); - float sinH = (tmp - 1.0 / tmp) / 2.0; - return sinH; -} - -vec2 cmul(vec2 a, vec2 b) { - return vec2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); -} - -vec2 cdiv(vec2 a, vec2 b) { - float denominator = b.x * b.x + b.y * b.y; - if (denominator == 0.) return a; - return cmul(a, vec2(b.x, -b.y)) / denominator; -} - -vec2 cpow(vec2 z, int n) { - vec2 res = z; - for (int i = 0; i < 20; i++) { - if (i >= n - 1) break; - res = cmul(z, res); - } - return res; -} - -vec2 cexp(vec2 z) { - return exp(z.x) * vec2(cos(z.y), sin(z.y)); -} - vec2 get_step(vec2 z) { vec2 value = cpow(z, 5) + 2.0 * cpow(z, 3) - vec2(1., 0.); vec2 derivative = 5.0 * cpow(z, 4) + 3.0 * cpow(z, 2); @@ -67,7 +29,7 @@ vec3 image(vec2 uv) { z = prevZ - cmul(factor, get_step(prevZ)); iterations++; - if (fabs(z.x - prevZ.x) < 0.001) break; + if (abs(z.x - prevZ.x) < 0.001) break; } float val = float(iterations) * 10.0 / float(MAX_ITERATIONS); -- cgit v1.3.1