Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Holcomb <bob_holcomb@hotmail.com>2010-03-13 17:47:26 +0300
committerRobert Holcomb <bob_holcomb@hotmail.com>2010-03-13 17:47:26 +0300
commitdfb59dbaa52d413068197176654f76cc84fceab8 (patch)
tree78f25fe9fc7454644a341ee404c332a8db9c309a
parent975cf38d6a78b60b0db899abd5a7dc950df133c5 (diff)
added method to change algorithm used in channel matte node. Limit a channel by another channel or limit by max of remaining channels.
-rw-r--r--source/blender/editors/space_node/drawnode.c15
-rw-r--r--source/blender/makesdna/DNA_node_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c21
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c85
4 files changed, 80 insertions, 42 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 16bf52db80f..9f7b01b1cd0 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -853,13 +853,24 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *C, Poin
{
uiLayout *col, *row;
+ uiItemL(layout, "Color Space:", 0);
row= uiLayoutRow(layout, 0);
uiItemR(row, NULL, 0, ptr, "color_space", UI_ITEM_R_EXPAND);
- row= uiLayoutRow(layout, 0);
+ col=uiLayoutColumn(layout, 0);
+ uiItemL(col, "Key Channel:", 0);
+ row= uiLayoutRow(col, 0);
uiItemR(row, NULL, 0, ptr, "channel", UI_ITEM_R_EXPAND);
- col =uiLayoutColumn(layout, 1);
+ col =uiLayoutColumn(layout, 0);
+
+ uiItemR(col, NULL, 0, ptr, "algorithm", 0);
+ if(RNA_enum_get(ptr, "algorithm")==0) {
+ uiItemL(col, "Limiting Channel:", 0);
+ row=uiLayoutRow(col,0);
+ uiItemR(row, NULL, 0, ptr, "limit_channel", UI_ITEM_R_EXPAND);
+ }
+
uiItemR(col, NULL, 0, ptr, "high", UI_ITEM_R_SLIDER);
uiItemR(col, NULL, 0, ptr, "low", UI_ITEM_R_SLIDER);
}
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index c178176048a..c587b2106ff 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -250,6 +250,7 @@ typedef struct NodeChroma {
float t1,t2,t3;
float fsize,fstrength,falpha;
float key[4];
+ short algorithm, channel;
} NodeChroma;
typedef struct NodeTwoXYs {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index c8b78b38b9a..ba805bd0a4f 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1425,6 +1425,11 @@ static void def_cmp_channel_matte(StructRNA *srna)
{CMP_NODE_CHANNEL_MATTE_CS_YUV, "YUV", 0, "YUV", "YUV Color Space"},
{CMP_NODE_CHANNEL_MATTE_CS_YCC, "YCC", 0, "YCbCr", "YCbCr Color Space"},
{0, NULL, 0, NULL, NULL}};
+
+ static EnumPropertyItem algorithm_items[] = {
+ {0, "SINGLE", 0, "Single", "Limit by single channel"},
+ {1, "MAX", 0, "Max", "Limit by max of other channels "},
+ {0, NULL, 0, NULL, NULL}};
prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
@@ -1432,15 +1437,27 @@ static void def_cmp_channel_matte(StructRNA *srna)
RNA_def_property_ui_text(prop, "Color Space", "");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-
prop= RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom2");
RNA_def_property_enum_items(prop, prop_tri_channel_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_channel_itemf");
RNA_def_property_ui_text(prop, "Channel", "Channel used to determine matte");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-
+
RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
+
+ prop = RNA_def_property(srna, "algorithm", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "algorithm");
+ RNA_def_property_enum_items(prop, algorithm_items);
+ RNA_def_property_ui_text(prop, "Algorithm", "Algorithm to use to limit channel");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "limit_channel", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "channel");
+ RNA_def_property_enum_items(prop, prop_tri_channel_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_channel_itemf");
+ RNA_def_property_ui_text(prop, "Limit Channel", "Limit by this channels value");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "high", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t1");
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c
index cda6cf06681..72990ed8fd2 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c
@@ -66,30 +66,36 @@ static void do_normalized_ycca_to_rgba2(bNode *node, float *out, float *in)
static void do_channel_matte(bNode *node, float *out, float *in)
{
NodeChroma *c=(NodeChroma *)node->storage;
- float alpha=0.0;
-
- /* Alpha=G-MAX(R, B) */
-
- switch(node->custom2)
- {
- case 1:
- {
- alpha=in[0]-MAX2(in[1],in[2]);
- break;
- }
- case 2:
- {
- alpha=in[1]-MAX2(in[0],in[2]);
- break;
- }
- case 3:
- {
- alpha=in[2]-MAX2(in[0],in[1]);
- break;
- }
- default:
- break;
- }
+ float alpha=0.0;
+
+ switch(c->algorithm) {
+ case 0: { /* Alpha=key_channel-limit channel */
+ int key_channel=node->custom2-1;
+ int limit_channel=c->channel-1;
+ alpha=in[key_channel]-in[limit_channel];
+ break;
+ }
+ case 1: { /* Alpha=G-MAX(R, B) */
+ switch(node->custom2) {
+ case 1: {
+ alpha=in[0]-MAX2(in[1],in[2]);
+ break;
+ }
+ case 2: {
+ alpha=in[1]-MAX2(in[0],in[2]);
+ break;
+ }
+ case 3: {
+ alpha=in[2]-MAX2(in[0],in[1]);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ default:
+ break;
+ }
/*flip because 0.0 is transparent, not 1.0*/
alpha=1-alpha;
@@ -120,6 +126,7 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack
{
CompBuf *cbuf;
CompBuf *outbuf;
+ NodeChroma *c=(NodeChroma *)node->storage;
if(in[0]->hasinput==0) return;
if(in[0]->data==NULL) return;
@@ -131,24 +138,24 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack
/*convert to colorspace*/
switch(node->custom1) {
- case CMP_NODE_CHANNEL_MATTE_CS_RGB:
- break;
- case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/
- composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_hsva, CB_RGBA);
- break;
- case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/
- composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_yuva, CB_RGBA);
- break;
- case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/
- composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_normalized_rgba_to_ycca2, CB_RGBA);
- break;
- default:
- break;
+ case CMP_NODE_CHANNEL_MATTE_CS_RGB:
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/
+ composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_hsva, CB_RGBA);
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/
+ composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_yuva, CB_RGBA);
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/
+ composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_normalized_rgba_to_ycca2, CB_RGBA);
+ break;
+ default:
+ break;
}
/*use the selected channel information to do the key */
composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_channel_matte, CB_RGBA);
-
+
/*convert back to RGB colorspace in place*/
switch(node->custom1) {
case CMP_NODE_CHANNEL_MATTE_CS_RGB: /*RGB*/
@@ -185,6 +192,8 @@ static void node_composit_init_channel_matte(bNode *node)
c->t3= 0.0f;
c->fsize= 0.0f;
c->fstrength= 0.0f;
+ c->algorithm=1; /*max channel limiting */
+ c->channel=1; /* limit by red */
node->custom1= 1; /* RGB channel */
node->custom2= 2; /* Green Channel */
}