diff options
author | Robert Holcomb <bob_holcomb@hotmail.com> | 2010-03-13 17:47:26 +0300 |
---|---|---|
committer | Robert Holcomb <bob_holcomb@hotmail.com> | 2010-03-13 17:47:26 +0300 |
commit | dfb59dbaa52d413068197176654f76cc84fceab8 (patch) | |
tree | 78f25fe9fc7454644a341ee404c332a8db9c309a /source/blender/nodes/intern/CMP_nodes | |
parent | 975cf38d6a78b60b0db899abd5a7dc950df133c5 (diff) |
added method to change algorithm used in channel matte node. Limit a channel by another channel or limit by max of remaining channels.
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes')
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c | 85 |
1 files changed, 47 insertions, 38 deletions
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 */ } |