Update Portuguese translation
[gegl.git] / opencl / vignette.cl
blob0c93b8525577a67486732b3a730c5c9f08989ace
1 __kernel void vignette_cl (__global const float4 *in,
2 __global float4 *out,
3 float4 color,
4 float scale,
5 float cost,
6 float sint,
7 int roi_x,
8 int roi_y,
9 int midx,
10 int midy,
11 int o_shape,
12 float gamma,
13 float length,
14 float radius0,
15 float rdiff)
17 int gidx = get_global_id(0);
18 int gidy = get_global_id(1);
19 int gid = gidx + gidy * get_global_size(0);
20 float strength = 0.0f;
21 float u,v,costy,sinty;
22 int x,y;
23 x = gidx + roi_x;
24 y = gidy + roi_y;
25 sinty = sint * (y-midy) - midx;
26 costy = cost * (y-midy) + midy;
28 u = cost * (x-midx) - sinty;
29 v = sint * (x-midx) + costy;
31 if (length == 0.0f)
32 strength = 0.0f;
33 else
35 switch (o_shape)
37 case 0:
38 strength = hypot ((u-midx) / scale, v-midy);
39 break;
41 case 1:
42 strength = fmax (fabs(u-midx)/scale, fabs(v-midy));
43 break;
45 case 2:
46 strength = fabs (u-midx) / scale + fabs(v-midy);
47 break;
49 case 3:
50 strength = fabs(v-midy);
51 break;
53 case 4:
54 strength = fabs (u-midx) / scale;
55 break;
57 strength /= length;
58 strength = (strength-radius0) / rdiff;
61 if (strength < 0.0f) strength = 0.0f;
62 if (strength > 1.0f) strength = 1.0f;
64 if (gamma > 1.9999f && gamma < 2.0001f)
65 strength *= strength;
66 else if (gamma != 1.0f)
67 strength = pow(strength, gamma);
69 out[gid] = in[gid]*(1.0f-strength) + color * strength;