Update Portuguese translation
[gegl.git] / opencl / noise-hurl.cl
blobd13674b46b350f5d740c47c003e3de86a4c0f6a3
1 /* This file is an image processing operation for GEGL
3 * GEGL is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 3 of the License, or (at your option) any later version.
8 * GEGL is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
16 * Copyright 2013 Carlos Zubieta <czubieta.dev@gmail.com>
19 __kernel void cl_noise_hurl(__global float4 *src,
20 __global const int *random_data,
21 int x_offset,
22 int y_offset,
23 int roi_width,
24 int whole_region_width,
25 GeglRandom rand,
26 float pct_random,
27 int gray,
28 int offset)
30 int gid = get_global_id(0);
31 int gidy = gid / roi_width;
32 int gidx = gid - gidy*roi_width;
34 int x = gidx + x_offset;
35 int y = gidy + y_offset;
36 int n = 4 * (x + whole_region_width * y + offset);
38 float4 src_v = src[gid];
40 float pc = gegl_cl_random_float_range (random_data,
41 rand, x, y, 0, n, 0, 100);
43 if(pc <= pct_random)
45 float red_noise = gegl_cl_random_float (random_data,
46 rand, x, y, 0, n+1);
48 src_v.x = red_noise;
49 if (gray == 0)
51 float green_noise = gegl_cl_random_float (random_data,
52 rand, x, y, 0, n+2);
53 float blue_noise = gegl_cl_random_float (random_data,
54 rand, x, y, 0, n+3);
55 src_v.y = green_noise;
56 src_v.z = blue_noise;
58 else
60 src_v.y = red_noise;
61 src_v.z = red_noise;
64 src[gid] = src_v;