diff options
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c')
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c index 151850105b7..55d77a902b9 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c @@ -49,16 +49,24 @@ static bNodeSocketType cmp_node_color_out[]={ static void do_color_key(bNode *node, float *out, float *in) { + float h_wrap; NodeChroma *c; c=node->storage; VECCOPY(out, in); - if(fabs(in[0]-c->key[0]) < c->t1 && - fabs(in[1]-c->key[1]) < c->t2 && - fabs(in[2]-c->key[2]) < c->t3) - { + if( + /* do hue last because it needs to wrap, and does some more checks */ + + /* sat */ (fabs(in[1]-c->key[1]) < c->t2) && + /* val */ (fabs(in[2]-c->key[2]) < c->t3) && + + /* multiply by 2 because it wraps on both sides of the hue, + * otherwise 0.5 would key all hue's */ + + /* hue */ ((h_wrap= 2.0f * fabs(in[0]-c->key[0])) < c->t1 || (2.0f - h_wrap) < c->t1) + ) { out[3]=0.0; /*make transparent*/ } |