summaryrefslogtreecommitdiff
path: root/mask_tests/kernel.c
diff options
context:
space:
mode:
authorBrett Weiland <brett_weiland@gmail.com>2024-06-11 14:50:14 -0500
committerBrett Weiland <brett_weiland@gmail.com>2024-06-11 14:50:14 -0500
commitcb69732f68c0bd46c1574de16ce1aee6f38e439b (patch)
treedef1daaec81a0d4cd7b3d44b2c26b9535e07579c /mask_tests/kernel.c
restartingHEADmaster
Diffstat (limited to 'mask_tests/kernel.c')
-rw-r--r--mask_tests/kernel.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/mask_tests/kernel.c b/mask_tests/kernel.c
new file mode 100644
index 0000000..669c382
--- /dev/null
+++ b/mask_tests/kernel.c
@@ -0,0 +1,49 @@
+unsigned int secant_fractal(double x, double y, unsigned int escape, unsigned int iterations) {
+ for(unsigned int iter = 0; iter < iterations; iter++) {
+ double next_x;
+ next_x = x / cos(y);
+ y = y / cos(x);
+ x = next_x;
+ if((pow(x, 2) + pow(y, 2)) >= escape) return iter;
+ }
+}
+unsigned int cosecant_fractal(double x, double y, unsigned int escape, unsigned int iterations) {
+ for(unsigned int iter = 0; iter < iterations; iter++) {
+ double next_x;
+ next_x = x / sin(y);
+ y = y / sin(x);
+ x = next_x;
+ if((pow(x, 2) + pow(y, 2)) >= escape) return iter;
+ }
+}
+
+double cosecant_single(double a, double b) { return a / sin(b); }
+double secant_single(double a, double b) { return a / tan(b); }
+
+
+__kernel void render_frame(__global unsigned int *frame_output, __global double *mask,
+ double x_step, double y_step,
+ double x_start, double y_start,
+ unsigned int iterations, unsigned int escape, double ratio) {
+ unsigned int result;
+ double x = (get_global_id(0) * x_step) + x_start;
+ double y = (get_global_id(1) * y_step) + y_start;
+ size_t img_index = (get_global_id(1) * get_global_size(1)) + get_global_id(0);
+
+ unsigned int iter;
+
+
+ for(iter = 0; iter < iterations; iter++) {
+ double next_x;
+ double r = mask[img_index];
+ next_x = (r * cosecant_single(x, y)) + ((1 - r) * secant_single(x, y));
+ y = (r * cosecant_single(y, x)) + ((1 - r) * secant_single(y, x));
+ x = next_x;
+ if((pow(x, 2) + pow(y, 2)) >= escape) break;
+ }
+
+
+
+ frame_output[img_index] = iter;
+ //frame_output[img_index] = mask[img_index] * 255;
+}