[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49849] trunk/blender/source/blender/ compositor/operations/COM_InpaintOperation.cpp: inpaint node now blend inpaint pixels with existing alpha, this makes soft alpha blends inpaint look nicer.

Campbell Barton ideasman42 at gmail.com
Sun Aug 12 19:31:42 CEST 2012


Revision: 49849
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49849
Author:   campbellbarton
Date:     2012-08-12 17:31:42 +0000 (Sun, 12 Aug 2012)
Log Message:
-----------
inpaint node now blend inpaint pixels with existing alpha, this makes soft alpha blends inpaint look nicer.

also dont assign 1.0 alpha for parts of the image not inpaint'ed, this way you can maintain some alpha in the image.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_InpaintOperation.cpp

Modified: trunk/blender/source/blender/compositor/operations/COM_InpaintOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_InpaintOperation.cpp	2012-08-12 17:30:45 UTC (rev 49848)
+++ trunk/blender/source/blender/compositor/operations/COM_InpaintOperation.cpp	2012-08-12 17:31:42 UTC (rev 49849)
@@ -57,7 +57,7 @@
 	this->initMutex();
 }
 
-void InpaintSimpleOperation::clamp_xy(int & x, int & y) 
+void InpaintSimpleOperation::clamp_xy(int &x, int &y)
 {
 	int width = this->getWidth();
 	int height = this->getHeight();
@@ -97,7 +97,7 @@
 	return this->m_manhatten_distance[y * width + x];
 }
 
-bool InpaintSimpleOperation::next_pixel(int & x, int & y, int & curr, int iters)
+bool InpaintSimpleOperation::next_pixel(int &x, int &y, int & curr, int iters)
 {
 	int width = this->getWidth();
 
@@ -110,7 +110,7 @@
 	x = r % width;
 	y = r / width;
 
-	if (mdist(x, y) > iters) {
+	if (this->mdist(x, y) > iters) {
 		return false;
 	}
 	
@@ -209,7 +209,10 @@
 
 	float *output = this->get_pixel(x, y);
 	if (pix_divider != 0.0f) {
-		mul_v3_v3fl(output, pix, 1.0f / pix_divider);
+		mul_v3_fl(pix, 1.0f / pix_divider);
+		/* use existing pixels alpha to blend into */
+		interp_v3_v3v3(output, pix, output, output[3]);
+		output[3] = 1.0f;
 	}
 }
 
@@ -225,14 +228,14 @@
 		this->m_cached_buffer = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS];
 		memcpy(this->m_cached_buffer, buf->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
 
-		calc_manhatten_distance();
+		this->calc_manhatten_distance();
 
 		int curr = 0;
 		int x, y;
 
 	
-		while (next_pixel(x, y, curr, this->m_iterations)) {
-			pix_step(x, y);
+		while (this->next_pixel(x, y, curr, this->m_iterations)) {
+			this->pix_step(x, y);
 		}
 		this->m_cached_buffer_ready = true;
 	}
@@ -244,8 +247,7 @@
 void InpaintSimpleOperation::executePixel(float output[4], int x, int y, void *data)
 {
 	this->clamp_xy(x, y);
-	copy_v3_v3(output, this->get_pixel(x, y));
-	output[3] = 1.0f;
+	copy_v4_v4(output, this->get_pixel(x, y));
 }
 
 void InpaintSimpleOperation::deinitExecution()




More information about the Bf-blender-cvs mailing list