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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
static const char* vignette_cl_source =
"__kernel void vignette_cl (__global const float4 *in, \n"
" __global float4 *out, \n"
" float4 color, \n"
" float scale, \n"
" float cost, \n"
" float sint, \n"
" int roi_x, \n"
" int roi_y, \n"
" int midx, \n"
" int midy, \n"
" int o_shape, \n"
" float gamma, \n"
" float length, \n"
" float radius0, \n"
" float rdiff) \n"
"{ \n"
" int gidx = get_global_id(0); \n"
" int gidy = get_global_id(1); \n"
" int gid = gidx + gidy * get_global_size(0); \n"
" float strength = 0.0f; \n"
" float u,v,costy,sinty; \n"
" int x,y; \n"
" x = gidx + roi_x; \n"
" y = gidy + roi_y; \n"
" sinty = sint * (y-midy) - midx; \n"
" costy = cost * (y-midy) + midy; \n"
" \n"
" u = cost * (x-midx) - sinty; \n"
" v = sint * (x-midx) + costy; \n"
" \n"
" if (length == 0.0f) \n"
" strength = 0.0f; \n"
" else \n"
" { \n"
" switch (o_shape) \n"
" { \n"
" case 0: \n"
" strength = hypot ((u-midx) / scale, v-midy); \n"
" break; \n"
" \n"
" case 1: \n"
" strength = fmax (fabs(u-midx)/scale, fabs(v-midy)); \n"
" break; \n"
" \n"
" case 2: \n"
" strength = fabs (u-midx) / scale + fabs(v-midy); \n"
" break; \n"
" } \n"
" strength /= length; \n"
" strength = (strength-radius0) / rdiff; \n"
" } \n"
" \n"
" if (strength < 0.0f) strength = 0.0f; \n"
" if (strength > 1.0f) strength = 1.0f; \n"
" \n"
" if (gamma > 0.9999f && gamma < 2.0001f) \n"
" strength *= strength; \n"
" else if (gamma != 1.0f) \n"
" strength = pow(strength, gamma); \n"
" \n"
" out[gid] = in[gid]*(1.0f-strength) + color * strength; \n"
"} \n"
;
|