[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48809] trunk/blender: Keying screen: small fixes and improvements from tomato

Sergey Sharybin sergey.vfx at gmail.com
Tue Jul 10 16:53:36 CEST 2012


Revision: 48809
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48809
Author:   nazgul
Date:     2012-07-10 14:53:36 +0000 (Tue, 10 Jul 2012)
Log Message:
-----------
Keying screen: small fixes and improvements from tomato

- Fixed issues with calculating matte with balance != 0.5
  It used to be used concave combination of minimal and maximal
  channel values which could be inpredictable.
  Use concave combination of two non-major channels sorted
  by their index, so such combination would always use the same
  coefficients for particular non-major channels.

- Added despill balance slider which defines balance between
  non-major channels used for calculating average of two
  colors. Difference between average value and pixel value of
  major screen channel defines amount of despill. Balance of
  0.5 gives the same behavior as it was before this slider
  was added.

---
svn merge -r48678:48679 -r48789:48790 ^/branches/soc-2011-tomato

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48678
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48789

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp
    trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.h
    trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.h
    trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_keying.c

Property Changed:
----------------
    trunk/blender/
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/space_outliner/


Property changes on: trunk/blender
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48792-48793
   + /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2012-07-10 14:43:50 UTC (rev 48808)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2012-07-10 14:53:36 UTC (rev 48809)
@@ -7011,6 +7011,21 @@
 	}
 }
 
+static void do_version_ntree_keying_despill_balance(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+	bNode *node;
+
+	for (node = ntree->nodes.first; node; node = node->next) {
+		if (node->type == CMP_NODE_KEYING) {
+			NodeKeyingData *data = node->storage;
+
+			if (data->despill_balance == 0.0f) {
+				data->despill_balance = 0.5f;
+			}
+		}
+	}
+}
+
 static void do_versions(FileData *fd, Library *lib, Main *main)
 {
 	/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -7825,6 +7840,13 @@
 			ntreetype->foreach_nodetree(main, NULL, do_version_ntree_dilateerode_264);
 	}
 
+	{
+		bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT);
+
+		if (ntreetype && ntreetype->foreach_nodetree)
+			ntreetype->foreach_nodetree(main, NULL, do_version_ntree_keying_despill_balance);
+	}
+
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
 	/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 

Modified: trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp	2012-07-10 14:43:50 UTC (rev 48808)
+++ trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp	2012-07-10 14:53:36 UTC (rev 48809)
@@ -184,11 +184,13 @@
 	return operationy->getOutputSocket();
 }
 
-OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, float factor)
+OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen,
+                                       float factor, float colorBalance)
 {
 	KeyingDespillOperation *despillOperation = new KeyingDespillOperation();
 
 	despillOperation->setDespillFactor(factor);
+	despillOperation->setColorBalance(colorBalance);
 
 	addLink(graph, despillInput, despillOperation->getInputSocket(0));
 	addLink(graph, inputScreen, despillOperation->getInputSocket(1));
@@ -292,7 +294,8 @@
 	if (keying_data->despill_factor > 0.0f) {
 		postprocessedImage = setupDespill(graph, postprocessedImage,
 		                                  keyingOperation->getInputSocket(1)->getConnection()->getFromSocket(),
-		                                  keying_data->despill_factor);
+		                                  keying_data->despill_factor,
+		                                  keying_data->despill_balance);
 	}
 
 	/* connect result to output sockets */

Modified: trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.h
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.h	2012-07-10 14:43:50 UTC (rev 48808)
+++ trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.h	2012-07-10 14:53:36 UTC (rev 48809)
@@ -36,7 +36,8 @@
 	OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance);
 	OutputSocket *setupFeather(ExecutionSystem *graph, CompositorContext *context, OutputSocket *featherInput,
 	                           int falloff, int distance);
-	OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, float factor);
+	OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen,
+	                           float factor, float colorBalance);
 	OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance,
 	                        float clipBlack, float clipWhite, bool edgeMatte);
 public:

Modified: trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp	2012-07-10 14:43:50 UTC (rev 48808)
+++ trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp	2012-07-10 14:53:36 UTC (rev 48809)
@@ -47,6 +47,7 @@
 	this->addOutputSocket(COM_DT_COLOR);
 
 	this->m_despillFactor = 0.5f;
+	this->m_colorBalance = 0.5f;
 
 	this->m_pixelReader = NULL;
 	this->m_screenReader = NULL;
@@ -73,16 +74,22 @@
 	this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers);
 
 	int screen_primary_channel = get_pixel_primary_channel(screenColor);
+	int other_1 = (screen_primary_channel + 1) % 3;
+	int other_2 = (screen_primary_channel + 2) % 3;
+
+	int min_channel = MIN2(other_1, other_2);
+	int max_channel = MAX2(other_1, other_2);
+
 	float average_value, amount;
 
-	average_value = (pixelColor[0] + pixelColor[1] + pixelColor[2] - pixelColor[screen_primary_channel]) / 2.0f;
-	amount = pixelColor[screen_primary_channel] - average_value;
+	average_value = this->m_colorBalance * pixelColor[min_channel] + (1.0f - this->m_colorBalance) * pixelColor[max_channel];
+	amount = (pixelColor[screen_primary_channel] - average_value);
 
 	color[0] = pixelColor[0];
 	color[1] = pixelColor[1];
 	color[2] = pixelColor[2];
 	color[3] = pixelColor[3];
-	
+
 	if (this->m_despillFactor * amount > 0) {
 		color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount;
 	}

Modified: trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.h	2012-07-10 14:43:50 UTC (rev 48808)
+++ trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.h	2012-07-10 14:53:36 UTC (rev 48809)
@@ -34,6 +34,7 @@
 	SocketReader *m_pixelReader;
 	SocketReader *m_screenReader;
 	float m_despillFactor;
+	float m_colorBalance;
 
 public:
 	KeyingDespillOperation();
@@ -42,6 +43,7 @@
 	void deinitExecution();
 
 	void setDespillFactor(float value) {this->m_despillFactor = value;}
+	void setColorBalance(float value) {this->m_colorBalance = value;}
 
 	void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
 };

Modified: trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp	2012-07-10 14:43:50 UTC (rev 48808)
+++ trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp	2012-07-10 14:53:36 UTC (rev 48809)
@@ -45,10 +45,11 @@
 	int other_1 = (primary_channel + 1) % 3;
 	int other_2 = (primary_channel + 2) % 3;
 
-	float min = MIN2(pixelColor[other_1], pixelColor[other_2]);
-	float max = MAX2(pixelColor[other_1], pixelColor[other_2]);
-	float val = screen_balance * min + (1.0f - screen_balance) * max;
+	int min_channel = MIN2(other_1, other_2);
+	int max_channel = MAX2(other_1, other_2);
 
+	float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel];
+
 	return (pixelColor[primary_channel] - val) * fabsf(1.0f - val);
 }
 


Property changes on: trunk/blender/source/blender/editors/interface/interface.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber/source/blender/editors/interface/interface.c:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato/source/blender/editors/interface/interface.c:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48792-48793
   + /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber/source/blender/editors/interface/interface.c:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list