diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-02-18 16:15:08 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-02-18 16:18:53 +0400 |
commit | 13553876ba3e18f49c2199d9c21f53ff2d8b2e41 (patch) | |
tree | 2cd84bc7914a2d174c1d98b6614c937b46c89f90 | |
parent | 69fb332709690a8c102e4fc282fe4ee5134f6dea (diff) |
Fix T38506: Bokeh blur node - size bugs with OpenCL.
The underlying cause for these issues is the insufficient sampling of
the bokeh image. For smaller blur radius there will be very few samples
taken, and with 1-pixel radius it boils down to just 4 samples:
2 on the left border (black), 1 in the center (black) and 1 at the top
border (blue) ...
For now have added the workarounds implemented in the CPU version of
that node, which hide these artifacts. Ultimately would be better to
have mipmap levels for the bokeh image input instead.
-rw-r--r-- | source/blender/compositor/operations/COM_OpenCLKernels.cl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl index d7a81001531..00b3825d8b3 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl @@ -41,6 +41,7 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima float4 bokeh; const float radius2 = radius*2.0f; const int2 realCoordinate = coords + offsetOutput; + int2 imageCoordinates = realCoordinate - offsetInput; tempBoundingBox = read_imagef(boundingBox, SAMPLER_NEAREST, coords).s0; @@ -54,6 +55,11 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima float2 uv; int2 inputXy; + if (radius < 2) { + color = read_imagef(inputImage, SAMPLER_NEAREST, imageCoordinates); + 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; @@ -65,10 +71,8 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima } } color /= multiplyer; - } else { - int2 imageCoordinates = realCoordinate - offsetInput; color = read_imagef(inputImage, SAMPLER_NEAREST, imageCoordinates); } |