diff options
author | David Phillips <david@sighup.nz> | 2017-03-03 23:25:57 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-03-03 23:25:57 +1300 |
commit | 9ada3fc9b6499cf591eeab248963e7144b267171 (patch) | |
tree | 0840736e27e50b720f257ad4138f226bf94ab5bc | |
parent | db9fa60833870bf6f70795a8b0a5b477d57bf570 (diff) | |
download | fractal-gen-opencl-9ada3fc9b6499cf591eeab248963e7144b267171.tar.xz |
Add burning ship fractal
-rw-r--r-- | cl/burning-ship.cl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cl/burning-ship.cl b/cl/burning-ship.cl new file mode 100644 index 0000000..7bab4b1 --- /dev/null +++ b/cl/burning-ship.cl @@ -0,0 +1,27 @@ +__kernel void fractal_gen( + __global unsigned char *buffer, + const unsigned int size, + const unsigned long iterations) +{ + unsigned int x = get_global_id(0); + unsigned int y = get_global_id(1); + unsigned long i = 0; + + float a = -2.5+(((float)x)/size)*3.5; + float b = -1.75+(((float)y)/size)*3.5; + + float2 z = (0.0, 0.0); + + for (i = 0; i < iterations; i++) { + // if abs(z) > 2 + if (z.x*z.x + z.y*z.y > 4) + break; + + float arez = fabs(z.x); + float aimz = fabs(z.y); + + z.x = arez*arez - aimz*aimz + a; + z.y = 2*aimz*arez + b; + } + buffer[(size*y)+x] = (i*255)/iterations; +} |