[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49715] trunk/blender/source/blender/ compositor/operations: add threshold blending to opencl too.

Campbell Barton ideasman42 at gmail.com
Wed Aug 8 20:10:13 CEST 2012


Revision: 49715
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49715
Author:   campbellbarton
Date:     2012-08-08 18:10:13 +0000 (Wed, 08 Aug 2012)
Log Message:
-----------
add threshold blending to opencl too.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl
    trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl.h
    trunk/blender/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp

Modified: trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl	2012-08-08 18:04:40 UTC (rev 49714)
+++ trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl	2012-08-08 18:10:13 UTC (rev 49715)
@@ -101,6 +101,7 @@
 		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 @@
 				}
 			} 
 		}
+
+		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);
 	}
-
-	color = color_accum * (1.0f / multiplier_accum);
-	write_imagef(output, coords, color);
 }
 
 

Modified: trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl.h	2012-08-08 18:04:40 UTC (rev 49714)
+++ trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl.h	2012-08-08 18:10:13 UTC (rev 49715)
@@ -103,6 +103,7 @@
 "		int2 inputCoordinate = realCoordinate - offsetInput;\n" \
 "		float size_center = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \
 "		color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \
+"		readColor = color_accum;\n" \
 "\n" \
 "		if (size_center > threshold) {\n" \
 "			for (int ny = miny; ny < maxy; ny += step) {\n" \
@@ -127,10 +128,20 @@
 "				}\n" \
 "			}\n" \
 "		}\n" \
+"\n" \
+"		color = color_accum * (1.0f / multiplier_accum);\n" \
+"\n" \
+"		/* blend in out values over the threshold, otherwise we get sharp, ugly transitions */\n" \
+"		if ((size_center > threshold) &&\n" \
+"		    (size_center < threshold * 2.0f))\n" \
+"		{\n" \
+"			/* factor from 0-1 */\n" \
+"			float fac = (size_center - threshold) / threshold;\n" \
+"			color = (readColor * (1.0f - fac)) +  (color * fac);\n" \
+"		}\n" \
+"\n" \
+"		write_imagef(output, coords, color);\n" \
 "	}\n" \
-"\n" \
-"	color = color_accum * (1.0f / multiplier_accum);\n" \
-"	write_imagef(output, coords, color);\n" \
 "}\n" \
 "\n" \
 "\n" \

Modified: trunk/blender/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp	2012-08-08 18:04:40 UTC (rev 49714)
+++ trunk/blender/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp	2012-08-08 18:10:13 UTC (rev 49715)
@@ -101,8 +101,8 @@
 	float readColor[4];
 	float bokeh[4];
 	float tempSize[4];
-	float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-	float color_accum[4]      = {0.0f, 0.0f, 0.0f, 0.0f};
+	float multiplier_accum[4];
+	float color_accum[4];
 	int maxBlur = tileData->maxBlur;
 
 #ifdef COM_DEFOCUS_SEARCH
@@ -122,8 +122,8 @@
 		inputSizeBuffer->readNoCheck(tempSize, x, y);
 		inputProgramBuffer->readNoCheck(readColor, x, y);
 
-		add_v4_v4(color_accum, readColor);
-		add_v4_fl(multiplier_accum, 1.0f);
+		copy_v4_v4(color_accum, readColor);
+		copy_v4_fl(multiplier_accum, 1.0f);
 		float size_center = tempSize[0];
 		
 		const int addXStep = QualityStepHelper::getStep() * COM_NUMBER_OF_CHANNELS;




More information about the Bf-blender-cvs mailing list