aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/shaders/newton.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/newton.glsl
parent49b6b0c9d7de093fc63af376afe5d03f1690995a (diff)
downloadart-playground-openrndr-686b2954a7cf0aae0493b4a974400aed64bbb96f.tar.gz
art-playground-openrndr-686b2954a7cf0aae0493b4a974400aed64bbb96f.zip
Add moth trtrfr
Diffstat (limited to '')
-rw-r--r--src/main/resources/shaders/newton.glsl42
1 files changed, 2 insertions, 40 deletions
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 <utils>
+#include <complex>
#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);