blob: d72148f3d6dde6e3d0fdefe2f5fcf0f9a67a4e80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
__kernel void fractal_gen(
__global unsigned char *buffer,
const unsigned int size,
const unsigned int iterations)
{
unsigned int x = get_global_id(0);
unsigned int y = get_global_id(1);
unsigned int 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 oldx = z.x;
z.x = z.x*z.x - z.y*z.y + a;
z.y = 2*oldx*z.y + b;
}
buffer[(size*y)+x] = (i*255)/iterations;
}
|