[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30989] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_colorSpill.c: added capabilty to limit color spill by an input mask

Robert Holcomb bob_holcomb at hotmail.com
Mon Aug 2 19:34:44 CEST 2010


Revision: 30989
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30989
Author:   scourage
Date:     2010-08-02 19:34:44 +0200 (Mon, 02 Aug 2010)

Log Message:
-----------
added capabilty to limit color spill by an input mask

Modified Paths:
--------------
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c	2010-08-02 16:57:46 UTC (rev 30988)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c	2010-08-02 17:34:44 UTC (rev 30989)
@@ -34,7 +34,8 @@
 
 /* ******************* Color Spill Supression ********************************* */
 static bNodeSocketType cmp_node_color_spill_in[]={
-	{SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+   {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+   {SOCK_VALUE, 1, "Fac",	1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 	{-1,0,""}
 };
 
@@ -50,6 +51,14 @@
 	out[0]=in[0]-( ncs->limscale * in[ncs->limchan] );
 }
 
+static void do_simple_spillmap_red_fac(bNode *node, float* out, float *in, float *fac)
+{
+   NodeColorspill *ncs;
+   ncs=node->storage;
+
+   out[0] = *fac * (in[0]-( ncs->limscale * in[ncs->limchan]));
+}
+
 static void do_simple_spillmap_green(bNode *node, float* out, float *in)
 {
 	NodeColorspill *ncs;
@@ -57,6 +66,14 @@
 	out[0]=in[1]-( ncs->limscale * in[ncs->limchan] );
 }
 
+static void do_simple_spillmap_green_fac(bNode *node, float* out, float *in, float *fac)
+{
+   NodeColorspill *ncs;
+   ncs=node->storage;
+
+   out[0] = *fac * (in[1]-( ncs->limscale * in[ncs->limchan]));
+}
+
 static void do_simple_spillmap_blue(bNode *node, float* out, float *in)
 {
 	NodeColorspill *ncs;
@@ -64,6 +81,14 @@
 	out[0]=in[2]-( ncs->limscale * in[ncs->limchan] );
 }
 
+static void do_simple_spillmap_blue_fac(bNode *node, float* out, float *in, float *fac)
+{
+   NodeColorspill *ncs;
+   ncs=node->storage;
+
+   out[0] = *fac * (in[2]-( ncs->limscale * in[ncs->limchan]));
+}
+
 static void do_average_spillmap_red(bNode *node, float* out, float *in)
 {
 	NodeColorspill *ncs;
@@ -71,6 +96,14 @@
 	out[0]=in[0]-(ncs->limscale * avg(in[1], in[2]) );
 }
 
+static void do_average_spillmap_red_fac(bNode *node, float* out, float *in, float *fac)
+{
+   NodeColorspill *ncs;
+   ncs=node->storage;
+
+   out[0] = *fac * (in[0]-(ncs->limscale * avg(in[1], in[2]) ));
+}
+
 static void do_average_spillmap_green(bNode *node, float* out, float *in)
 {
 	NodeColorspill *ncs;
@@ -78,6 +111,14 @@
 	out[0]=in[1]-(ncs->limscale * avg(in[0], in[2]) );
 }
 
+static void do_average_spillmap_green_fac(bNode *node, float* out, float *in, float *fac)
+{
+   NodeColorspill *ncs;
+   ncs=node->storage;
+
+   out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[2]) ));
+}
+
 static void do_average_spillmap_blue(bNode *node, float* out, float *in)
 {
 	NodeColorspill *ncs;
@@ -85,6 +126,14 @@
 	out[0]=in[2]-(ncs->limscale * avg(in[0], in[1]) );
 }
 
+static void do_average_spillmap_blue_fac(bNode *node, float* out, float *in, float *fac)
+{
+   NodeColorspill *ncs;
+   ncs=node->storage;
+
+   out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[1]) ));
+}
+
 static void do_apply_spillmap_red(bNode *node, float* out, float *in, float *map)
 {	
 	NodeColorspill *ncs;
@@ -109,7 +158,7 @@
 		out[0]=in[0]+(ncs->uspillr*map[0]);
 		out[1]=in[1]-(ncs->uspillg*map[0]);
 		out[2]=in[2]+(ncs->uspillb*map[0]);
-	 }
+   }
 	else {
 		out[0]=in[0];
 		out[1]=in[1];
@@ -125,7 +174,7 @@
 		out[0]=in[0]+(ncs->uspillr*map[0]);
 		out[1]=in[1]+(ncs->uspillg*map[0]);
 		out[2]=in[2]-(ncs->uspillb*map[0]);
-	 }
+   }
 	else {
 		out[0]=in[0];
 		out[1]=in[1];
@@ -138,16 +187,20 @@
 	/*
 	Originally based on the information from the book "The Art and Science of Digital Composition" and 
 	discussions from vfxtalk.com.*/
-	CompBuf *cbuf;
+   CompBuf *cbuf;
+   CompBuf *mask;
 	CompBuf *rgbbuf;
 	CompBuf *spillmap;
 	NodeColorspill *ncs;
 	ncs=node->storage;
+
+   /* early out for missing connections */
+   if(out[0]->hasoutput==0 ) return;
+   if(in[0]->hasinput==0) return;
+   if(in[0]->data==NULL) return;
 	
-	if(out[0]->hasoutput==0 || in[0]->hasinput==0) return;
-	if(in[0]->data==NULL) return;
-	
-	cbuf=typecheck_compbuf(in[0]->data, CB_RGBA);
+   cbuf=typecheck_compbuf(in[0]->data, CB_RGBA);
+   mask=typecheck_compbuf(in[1]->data, CB_VAL);
 	spillmap=alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1);
 	rgbbuf=dupalloc_compbuf(cbuf);
 
@@ -157,14 +210,22 @@
 		{
 			switch(node->custom2)
 			{
-				case 0: /* simple limit */
-				{
-					composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_red, CB_RGBA);
+         case 0: /* simple limit */
+            {
+               if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+                  composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_red, CB_RGBA);
+               } else {
+                  composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_red_fac, CB_RGBA,  CB_VAL);
+               }
 					break;
 				}
-				case 1: /* average limit */
-				{
-					composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_red, CB_RGBA);
+         case 1: /* average limit */
+            {
+               if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+                  composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_red, CB_RGBA);
+               } else {
+                  composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_red_fac, CB_RGBA,  CB_VAL);
+               }
 					break;
 				}
 			}
@@ -180,22 +241,30 @@
 		{
 			switch(node->custom2)
 			{
-				case 0: /* simple limit */
-				{
-					composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_green, CB_RGBA);
-					break;
-				}
-				case 1: /* average limit */
-				{
-					composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_green, CB_RGBA);
-					break;
-				}
+         case 0: /* simple limit */
+            {
+               if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+                  composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_green, CB_RGBA);
+               } else {
+                  composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_green_fac, CB_RGBA,  CB_VAL);
+               }
+               break;
+            }
+         case 1: /* average limit */
+            {
+               if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+                  composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_green, CB_RGBA);
+               } else {
+                  composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_green_fac, CB_RGBA,  CB_VAL);
+               }
+               break;
+            }
 			}
 			if(ncs->unspill==0) {
 				ncs->uspillr=0.0f;
 				ncs->uspillg=1.0f;
 				ncs->uspillb=0.0f;
-			}
+         }
 			composit2_pixel_processor(node, rgbbuf, cbuf, in[0]->vec, spillmap, NULL, do_apply_spillmap_green, CB_RGBA, CB_VAL);
 			break;
 		}
@@ -203,16 +272,24 @@
 		{
 			switch(node->custom2)
 			{
-				case 0: /* simple limit */
-				{
-					composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_blue, CB_RGBA);
-					break;
-				}
-				case 1: /* average limit */
-				{
-					composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_blue, CB_RGBA);
-					break;
-				}
+         case 0: /* simple limit */
+            {
+               if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+                  composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_blue, CB_RGBA);
+               } else {
+                  composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_blue_fac, CB_RGBA,  CB_VAL);
+               }
+               break;
+            }
+         case 1: /* average limit */
+            {
+               if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+                  composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_blue, CB_RGBA);
+               } else {
+                  composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_blue_fac, CB_RGBA,  CB_VAL);
+               }
+               break;
+            }
 			}
 			if(ncs->unspill==0) {
 				ncs->uspillr=0.0f;
@@ -246,19 +323,18 @@
 }
 
 bNodeType cmp_node_color_spill={
-	/* *next,*prev */	NULL, NULL,
-	/* type code   */	CMP_NODE_COLOR_SPILL,
-	/* name        */	"Color Spill",
-	/* width+range */	140, 80, 200,
-	/* class+opts  */	NODE_CLASS_MATTE, NODE_OPTIONS,
-	/* input sock  */	cmp_node_color_spill_in,
-	/* output sock */	cmp_node_color_spill_out,
-	/* storage     */	"NodeColorspill",
-	/* execfunc    */	node_composit_exec_color_spill,
-	/* butfunc     */	NULL,
-	/* initfunc    */	node_composit_init_color_spill,
-	/* freestoragefunc    */	node_free_standard_storage,
-	/* copystoragefunc    */	node_copy_standard_storage,
-	/* id          */	NULL
+   /* *next,*prev */	NULL, NULL,
+   /* type code   */	CMP_NODE_COLOR_SPILL,
+   /* name        */	"Color Spill",
+   /* width+range */	140, 80, 200,
+   /* class+opts  */	NODE_CLASS_MATTE, NODE_OPTIONS,
+   /* input sock  */	cmp_node_color_spill_in,
+   /* output sock */	cmp_node_color_spill_out,
+   /* storage     */	"NodeColorspill",
+   /* execfunc    */	node_composit_exec_color_spill,
+   /* butfunc     */	NULL,
+   /* initfunc    */	node_composit_init_color_spill,
+   /* freestoragefunc    */	node_free_standard_storage,
+   /* copystoragefunc    */	node_copy_standard_storage,
 };
 





More information about the Bf-blender-cvs mailing list