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.cl75
1 files changed, 69 insertions, 6 deletions
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl
index 00b3825d8b3..cbd05cbec17 100644
--- a/source/blender/compositor/operations/COM_OpenCLKernels.cl
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl
@@ -80,10 +80,10 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima
}
//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 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)
{
float4 color = {1.0f, 0.0f, 0.0f, 1.0f};
int2 coords = {get_global_id(0), get_global_id(1)};
@@ -212,8 +212,8 @@ __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,
- float2 center, int2 offset)
+ int2 offsetOutput, int iterations, float scale, float rotation, float2 translate,
+ float2 center, int2 offset)
{
int2 coords = {get_global_id(0), get_global_id(1)};
coords += offset;
@@ -250,3 +250,66 @@ __kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_o
write_imagef(output, coords, col);
}
+
+// KERNEL --- GAUSSIAN BLUR ---
+__kernel void gaussianXBlurOperationKernel(__read_only image2d_t inputImage,
+ int2 offsetInput,
+ __write_only image2d_t output,
+ int2 offsetOutput,
+ int filter_size,
+ int2 dimension,
+ __global float *gausstab,
+ int2 offset)
+{
+ 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;
+ 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;
+
+ for (int nx = xmin, i = max(filter_size - realCoordinate.x, 0); nx < xmax; ++nx, ++i) {
+ float w = gausstab[i];
+ inputCoordinate.x = nx;
+ color += read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate) * w;
+ weight += w;
+ }
+
+ color *= (1.0f / weight);
+
+ write_imagef(output, coords, color);
+}
+
+__kernel void gaussianYBlurOperationKernel(__read_only image2d_t inputImage,
+ int2 offsetInput,
+ __write_only image2d_t output,
+ int2 offsetOutput,
+ int filter_size,
+ int2 dimension,
+ __global float *gausstab,
+ int2 offset)
+{
+ 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;
+ 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;
+
+ for (int ny = ymin, i = max(filter_size - realCoordinate.y, 0); ny < ymax; ++ny, ++i) {
+ float w = gausstab[i];
+ inputCoordinate.y = ny;
+ color += read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate) * w;
+ weight += w;
+ }
+
+ color *= (1.0f / weight);
+
+ write_imagef(output, coords, color);
+}