diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-08 22:10:13 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-08 22:10:13 +0400 |
commit | 5019cd179f39ee8f80829bb0d6895e494a66ffa2 (patch) | |
tree | 38727d9646468394de783fd49554873495248638 /source/blender/compositor/operations/COM_OpenCLKernels.cl | |
parent | a401971cf88e3acadb04243929822da6fcf03174 (diff) |
add threshold blending to opencl too.
Diffstat (limited to 'source/blender/compositor/operations/COM_OpenCLKernels.cl')
-rw-r--r-- | source/blender/compositor/operations/COM_OpenCLKernels.cl | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl index 441f6af79a5..9a89fe21414 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl @@ -101,6 +101,7 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 int2 inputCoordinate = realCoordinate - offsetInput; float size_center = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); + readColor = color_accum; if (size_center > threshold) { for (int ny = miny; ny < maxy; ny += step) { @@ -125,10 +126,20 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 } } } - } - color = color_accum * (1.0f / multiplier_accum); - write_imagef(output, coords, color); + color = color_accum * (1.0f / multiplier_accum); + + /* blend in out values over the threshold, otherwise we get sharp, ugly transitions */ + if ((size_center > threshold) && + (size_center < threshold * 2.0f)) + { + /* factor from 0-1 */ + float fac = (size_center - threshold) / threshold; + color = (readColor * (1.0f - fac)) + (color * fac); + } + + write_imagef(output, coords, color); + } } |