[Bf-blender-cvs] [1355387] master: Fix T38506: Bokeh blur node - size bugs with OpenCL.

Lukas Tönne noreply at git.blender.org
Tue Feb 18 13:23:46 CET 2014


Commit: 13553876ba3e18f49c2199d9c21f53ff2d8b2e41
Author: Lukas Tönne
Date:   Tue Feb 18 13:15:08 2014 +0100
https://developer.blender.org/rB13553876ba3e18f49c2199d9c21f53ff2d8b2e41

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.

===================================================================

M	source/blender/compositor/operations/COM_OpenCLKernels.cl

===================================================================

diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl
index d7a8100..00b3825 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);
 	}




More information about the Bf-blender-cvs mailing list