Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/operations/COM_OpenCLKernels.cl')
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl196
1 files changed, 98 insertions, 98 deletions
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl
index ebe8a6d08ec..d01e209d3e4 100644
--- a/source/blender/compositor/operations/COM_OpenCLKernels.cl
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl
@@ -29,101 +29,101 @@ const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRES
__constant const int2 zero = {0,0};
// KERNEL --- BOKEH BLUR ---
-__kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only image2d_t inputImage,
- __read_only image2d_t bokehImage, __write_only image2d_t output,
- int2 offsetInput, int2 offsetOutput, int radius, int step, int2 dimension, int2 offset)
+__kernel void bokeh_blur_kernel(__read_only image2d_t bounding_box, __read_only image2d_t input_image,
+ __read_only image2d_t bokeh_image, __write_only image2d_t output,
+ int2 offset_input, int2 offset_output, int radius, int step, int2 dimension, int2 offset)
{
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
- float tempBoundingBox;
+ float temp_bounding_box;
float4 color = {0.0f,0.0f,0.0f,0.0f};
float4 multiplyer = {0.0f,0.0f,0.0f,0.0f};
float4 bokeh;
const float radius2 = radius*2.0f;
- const int2 realCoordinate = coords + offsetOutput;
- int2 imageCoordinates = realCoordinate - offsetInput;
+ const int2 real_coordinate = coords + offset_output;
+ int2 image_coordinates = real_coordinate - offset_input;
- tempBoundingBox = read_imagef(boundingBox, SAMPLER_NEAREST, coords).s0;
+ temp_bounding_box = read_imagef(bounding_box, SAMPLER_NEAREST, coords).s0;
- if (tempBoundingBox > 0.0f && radius > 0 ) {
- const int2 bokehImageDim = get_image_dim(bokehImage);
- const int2 bokehImageCenter = bokehImageDim/2;
- const int2 minXY = max(realCoordinate - radius, zero);
- const int2 maxXY = min(realCoordinate + radius, dimension);
+ if (temp_bounding_box > 0.0f && radius > 0 ) {
+ const int2 bokeh_image_dim = get_image_dim(bokeh_image);
+ const int2 bokeh_image_center = bokeh_image_dim/2;
+ const int2 minXY = max(real_coordinate - radius, zero);
+ const int2 maxXY = min(real_coordinate + radius, dimension);
int nx, ny;
float2 uv;
- int2 inputXy;
+ int2 input_xy;
if (radius < 2) {
- color = read_imagef(inputImage, SAMPLER_NEAREST, imageCoordinates);
+ color = read_imagef(input_image, SAMPLER_NEAREST, image_coordinates);
multiplyer = (float4)(1.0f, 1.0f, 1.0f, 1.0f);
}
- for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny += step, inputXy.y += step) {
- uv.y = ((realCoordinate.y-ny)/radius2)*bokehImageDim.y+bokehImageCenter.y;
+ for (ny = minXY.y, input_xy.y = ny - offset_input.y ; ny < maxXY.y ; ny += step, input_xy.y += step) {
+ uv.y = ((real_coordinate.y-ny)/radius2)*bokeh_image_dim.y+bokeh_image_center.y;
- for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx += step, inputXy.x += step) {
- uv.x = ((realCoordinate.x-nx)/radius2)*bokehImageDim.x+bokehImageCenter.x;
- bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);
- color += bokeh * read_imagef(inputImage, SAMPLER_NEAREST, inputXy);
+ for (nx = minXY.x, input_xy.x = nx - offset_input.x; nx < maxXY.x ; nx += step, input_xy.x += step) {
+ uv.x = ((real_coordinate.x-nx)/radius2)*bokeh_image_dim.x+bokeh_image_center.x;
+ bokeh = read_imagef(bokeh_image, SAMPLER_NEAREST, uv);
+ color += bokeh * read_imagef(input_image, SAMPLER_NEAREST, input_xy);
multiplyer += bokeh;
}
}
color /= multiplyer;
}
else {
- color = read_imagef(inputImage, SAMPLER_NEAREST, imageCoordinates);
+ color = read_imagef(input_image, SAMPLER_NEAREST, image_coordinates);
}
write_imagef(output, coords, color);
}
//KERNEL --- DEFOCUS /VARIABLESIZEBOKEHBLUR ---
-__kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2d_t bokehImage,
- __read_only image2d_t inputSize,
- __write_only image2d_t output, int2 offsetInput, int2 offsetOutput,
- int step, int maxBlurScalar, float threshold, float scalar, int2 dimension, int2 offset)
+__kernel void defocus_kernel(__read_only image2d_t input_image, __read_only image2d_t bokeh_image,
+ __read_only image2d_t input_size,
+ __write_only image2d_t output, int2 offset_input, int2 offset_output,
+ int step, int max_blur_scalar, float threshold, float scalar, int2 dimension, int2 offset)
{
float4 color = {1.0f, 0.0f, 0.0f, 1.0f};
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
- const int2 realCoordinate = coords + offsetOutput;
+ const int2 real_coordinate = coords + offset_output;
- float4 readColor;
- float4 tempColor;
+ float4 read_color;
+ float4 temp_color;
float4 bokeh;
float size;
float4 multiplier_accum = {1.0f, 1.0f, 1.0f, 1.0f};
float4 color_accum;
- int minx = max(realCoordinate.s0 - maxBlurScalar, 0);
- int miny = max(realCoordinate.s1 - maxBlurScalar, 0);
- int maxx = min(realCoordinate.s0 + maxBlurScalar, dimension.s0);
- int maxy = min(realCoordinate.s1 + maxBlurScalar, dimension.s1);
+ int minx = max(real_coordinate.s0 - max_blur_scalar, 0);
+ int miny = max(real_coordinate.s1 - max_blur_scalar, 0);
+ int maxx = min(real_coordinate.s0 + max_blur_scalar, dimension.s0);
+ int maxy = min(real_coordinate.s1 + max_blur_scalar, dimension.s1);
{
- int2 inputCoordinate = realCoordinate - offsetInput;
- float size_center = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0 * scalar;
- color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);
- readColor = color_accum;
+ int2 input_coordinate = real_coordinate - offset_input;
+ float size_center = read_imagef(input_size, SAMPLER_NEAREST, input_coordinate).s0 * scalar;
+ color_accum = read_imagef(input_image, SAMPLER_NEAREST, input_coordinate);
+ read_color = color_accum;
if (size_center > threshold) {
for (int ny = miny; ny < maxy; ny += step) {
- inputCoordinate.s1 = ny - offsetInput.s1;
- float dy = ny - realCoordinate.s1;
+ input_coordinate.s1 = ny - offset_input.s1;
+ float dy = ny - real_coordinate.s1;
for (int nx = minx; nx < maxx; nx += step) {
- float dx = nx - realCoordinate.s0;
+ float dx = nx - real_coordinate.s0;
if (dx != 0 || dy != 0) {
- inputCoordinate.s0 = nx - offsetInput.s0;
- size = min(read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0 * scalar, size_center);
+ input_coordinate.s0 = nx - offset_input.s0;
+ size = min(read_imagef(input_size, SAMPLER_NEAREST, input_coordinate).s0 * scalar, size_center);
if (size > threshold) {
if (size >= fabs(dx) && size >= fabs(dy)) {
float2 uv = {256.0f + dx * 255.0f / size,
256.0f + dy * 255.0f / size};
- bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);
- tempColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);
- color_accum += bokeh * tempColor;
+ bokeh = read_imagef(bokeh_image, SAMPLER_NEAREST, uv);
+ temp_color = read_imagef(input_image, SAMPLER_NEAREST, input_coordinate);
+ color_accum += bokeh * temp_color;
multiplier_accum += bokeh;
}
}
@@ -140,7 +140,7 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2
{
/* factor from 0-1 */
float fac = (size_center - threshold) / threshold;
- color = (readColor * (1.0f - fac)) + (color * fac);
+ color = (read_color * (1.0f - fac)) + (color * fac);
}
write_imagef(output, coords, color);
@@ -149,28 +149,28 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2
// KERNEL --- DILATE ---
-__kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image2d_t output,
- int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,
+__kernel void dilate_kernel(__read_only image2d_t input_image, __write_only image2d_t output,
+ int2 offset_input, int2 offset_output, int scope, int distance_squared, int2 dimension,
int2 offset)
{
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
- const int2 realCoordinate = coords + offsetOutput;
+ const int2 real_coordinate = coords + offset_output;
- const int2 minXY = max(realCoordinate - scope, zero);
- const int2 maxXY = min(realCoordinate + scope, dimension);
+ const int2 minXY = max(real_coordinate - scope, zero);
+ const int2 maxXY = min(real_coordinate + scope, dimension);
float value = 0.0f;
int nx, ny;
- int2 inputXy;
+ int2 input_xy;
- for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny ++, inputXy.y++) {
- const float deltaY = (realCoordinate.y - ny);
- for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx ++, inputXy.x++) {
- const float deltaX = (realCoordinate.x - nx);
- const float measuredDistance = deltaX * deltaX + deltaY * deltaY;
- if (measuredDistance <= distanceSquared) {
- value = max(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
+ for (ny = minXY.y, input_xy.y = ny - offset_input.y ; ny < maxXY.y ; ny ++, input_xy.y++) {
+ const float deltaY = (real_coordinate.y - ny);
+ for (nx = minXY.x, input_xy.x = nx - offset_input.x; nx < maxXY.x ; nx ++, input_xy.x++) {
+ const float deltaX = (real_coordinate.x - nx);
+ const float measured_distance = deltaX * deltaX + deltaY * deltaY;
+ if (measured_distance <= distance_squared) {
+ value = max(value, read_imagef(input_image, SAMPLER_NEAREST, input_xy).s0);
}
}
}
@@ -180,28 +180,28 @@ __kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image
}
// KERNEL --- DILATE ---
-__kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2d_t output,
- int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension,
+__kernel void erode_kernel(__read_only image2d_t input_image, __write_only image2d_t output,
+ int2 offset_input, int2 offset_output, int scope, int distance_squared, int2 dimension,
int2 offset)
{
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
- const int2 realCoordinate = coords + offsetOutput;
+ const int2 real_coordinate = coords + offset_output;
- const int2 minXY = max(realCoordinate - scope, zero);
- const int2 maxXY = min(realCoordinate + scope, dimension);
+ const int2 minXY = max(real_coordinate - scope, zero);
+ const int2 maxXY = min(real_coordinate + scope, dimension);
float value = 1.0f;
int nx, ny;
- int2 inputXy;
+ int2 input_xy;
- for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny ++, inputXy.y++) {
- for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx ++, inputXy.x++) {
- const float deltaX = (realCoordinate.x - nx);
- const float deltaY = (realCoordinate.y - ny);
- const float measuredDistance = deltaX * deltaX+deltaY * deltaY;
- if (measuredDistance <= distanceSquared) {
- value = min(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
+ for (ny = minXY.y, input_xy.y = ny - offset_input.y ; ny < maxXY.y ; ny ++, input_xy.y++) {
+ for (nx = minXY.x, input_xy.x = nx - offset_input.x; nx < maxXY.x ; nx ++, input_xy.x++) {
+ const float deltaX = (real_coordinate.x - nx);
+ const float deltaY = (real_coordinate.y - ny);
+ const float measured_distance = deltaX * deltaX+deltaY * deltaY;
+ if (measured_distance <= distance_squared) {
+ value = min(value, read_imagef(input_image, SAMPLER_NEAREST, input_xy).s0);
}
}
}
@@ -211,34 +211,34 @@ __kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2
}
// KERNEL --- DIRECTIONAL BLUR ---
-__kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_only image2d_t output,
- int2 offsetOutput, int iterations, float scale, float rotation, float2 translate,
+__kernel void directional_blur_kernel(__read_only image2d_t input_image, __write_only image2d_t output,
+ int2 offset_output, int iterations, float scale, float rotation, float2 translate,
float2 center, int2 offset)
{
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
- const int2 realCoordinate = coords + offsetOutput;
+ const int2 real_coordinate = coords + offset_output;
float4 col;
float2 ltxy = translate;
float lsc = scale;
float lrot = rotation;
- col = read_imagef(inputImage, SAMPLER_NEAREST, realCoordinate);
+ col = read_imagef(input_image, SAMPLER_NEAREST, real_coordinate);
/* blur the image */
for (int i = 0; i < iterations; ++i) {
const float cs = cos(lrot), ss = sin(lrot);
const float isc = 1.0f / (1.0f + lsc);
- const float v = isc * (realCoordinate.s1 - center.s1) + ltxy.s1;
- const float u = isc * (realCoordinate.s0 - center.s0) + ltxy.s0;
+ const float v = isc * (real_coordinate.s1 - center.s1) + ltxy.s1;
+ const float u = isc * (real_coordinate.s0 - center.s0) + ltxy.s0;
float2 uv = {
cs * u + ss * v + center.s0,
cs * v - ss * u + center.s1
};
- col += read_imagef(inputImage, SAMPLER_NEAREST_CLAMP, uv);
+ col += read_imagef(input_image, SAMPLER_NEAREST_CLAMP, uv);
/* double transformations */
ltxy += translate;
@@ -252,10 +252,10 @@ __kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_o
}
// KERNEL --- GAUSSIAN BLUR ---
-__kernel void gaussianXBlurOperationKernel(__read_only image2d_t inputImage,
- int2 offsetInput,
+__kernel void gaussian_xblur_operation_kernel(__read_only image2d_t input_image,
+ int2 offset_input,
__write_only image2d_t output,
- int2 offsetOutput,
+ int2 offset_output,
int filter_size,
int2 dimension,
__global float *gausstab,
@@ -264,17 +264,17 @@ __kernel void gaussianXBlurOperationKernel(__read_only image2d_t inputImage,
float4 color = {0.0f, 0.0f, 0.0f, 0.0f};
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
- const int2 realCoordinate = coords + offsetOutput;
- int2 inputCoordinate = realCoordinate - offsetInput;
+ const int2 real_coordinate = coords + offset_output;
+ int2 input_coordinate = real_coordinate - offset_input;
float weight = 0.0f;
- int xmin = max(realCoordinate.x - filter_size, 0) - offsetInput.x;
- int xmax = min(realCoordinate.x + filter_size + 1, dimension.x) - offsetInput.x;
+ int xmin = max(real_coordinate.x - filter_size, 0) - offset_input.x;
+ int xmax = min(real_coordinate.x + filter_size + 1, dimension.x) - offset_input.x;
- for (int nx = xmin, i = max(filter_size - realCoordinate.x, 0); nx < xmax; ++nx, ++i) {
+ for (int nx = xmin, i = max(filter_size - real_coordinate.x, 0); nx < xmax; ++nx, ++i) {
float w = gausstab[i];
- inputCoordinate.x = nx;
- color += read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate) * w;
+ input_coordinate.x = nx;
+ color += read_imagef(input_image, SAMPLER_NEAREST, input_coordinate) * w;
weight += w;
}
@@ -283,10 +283,10 @@ __kernel void gaussianXBlurOperationKernel(__read_only image2d_t inputImage,
write_imagef(output, coords, color);
}
-__kernel void gaussianYBlurOperationKernel(__read_only image2d_t inputImage,
- int2 offsetInput,
+__kernel void gaussian_yblur_operation_kernel(__read_only image2d_t input_image,
+ int2 offset_input,
__write_only image2d_t output,
- int2 offsetOutput,
+ int2 offset_output,
int filter_size,
int2 dimension,
__global float *gausstab,
@@ -295,17 +295,17 @@ __kernel void gaussianYBlurOperationKernel(__read_only image2d_t inputImage,
float4 color = {0.0f, 0.0f, 0.0f, 0.0f};
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
- const int2 realCoordinate = coords + offsetOutput;
- int2 inputCoordinate = realCoordinate - offsetInput;
+ const int2 real_coordinate = coords + offset_output;
+ int2 input_coordinate = real_coordinate - offset_input;
float weight = 0.0f;
- int ymin = max(realCoordinate.y - filter_size, 0) - offsetInput.y;
- int ymax = min(realCoordinate.y + filter_size + 1, dimension.y) - offsetInput.y;
+ int ymin = max(real_coordinate.y - filter_size, 0) - offset_input.y;
+ int ymax = min(real_coordinate.y + filter_size + 1, dimension.y) - offset_input.y;
- for (int ny = ymin, i = max(filter_size - realCoordinate.y, 0); ny < ymax; ++ny, ++i) {
+ for (int ny = ymin, i = max(filter_size - real_coordinate.y, 0); ny < ymax; ++ny, ++i) {
float w = gausstab[i];
- inputCoordinate.y = ny;
- color += read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate) * w;
+ input_coordinate.y = ny;
+ color += read_imagef(input_image, SAMPLER_NEAREST, input_coordinate) * w;
weight += w;
}