From 37308c01caec3f5e97960bb961007d059d49d6a8 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 7 Mar 2007 11:09:03 +0000 Subject: [PATCH] Compositor/assorted nodes fixes: * Auto-create compbufs for first socket of alphaover and set alpha nodes. This allows you to eg. plug something into the second socket of an alphaover node, and choose a solid colour in the first empty socket for the image to be superimposed over. Previously I had to create a bunch of extra nodes to (for example) mix 100% black over my render, just to get a black compbuf of the right size that I could plug in. Not nice. The Mix node already works this way, and these two should have, but didn't. * Allow the 'Fac' value to be used on RGB curves when there is no input image. This lets you easily fade the changes in and out to check it against the original, or to tone down the effect of the colour correction. --- source/blender/blenkernel/intern/node.c | 2 +- .../blender/blenkernel/intern/node_composite.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 6c72b087e47..62246fa59c5 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -753,7 +753,7 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup) node->type= ntype->type; node->flag= NODE_SELECT|ntype->flag; node->width= ntype->width; - node->miniwidth= 15.0f; /* small value only, allows print of first chars */ + node->miniwidth= 42.0f; /* small value only, allows print of first chars */ if(type==NODE_GROUP) node->id= (ID *)ngroup; diff --git a/source/blender/blenkernel/intern/node_composite.c b/source/blender/blenkernel/intern/node_composite.c index 1eb13a8ae23..4a54c53bb9d 100644 --- a/source/blender/blenkernel/intern/node_composite.c +++ b/source/blender/blenkernel/intern/node_composite.c @@ -1521,10 +1521,11 @@ static void node_composit_exec_curve_rgb(void *data, bNode *node, bNodeStack **i CompBuf *cbuf= in[1]->data; CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ - if(in[0]->data) - composit2_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[0]->data, in[0]->vec, do_curves_fac, CB_RGBA, CB_VAL); - else + if(in[0]->vec[0] == 1.0) composit1_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, do_curves, CB_RGBA); + else + composit2_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[0]->data, in[0]->vec, do_curves_fac, CB_RGBA, CB_VAL); + out[0]->data= stackbuf; } @@ -1719,7 +1720,7 @@ static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, static bNodeType cmp_node_mix_rgb= { /* type code */ CMP_NODE_MIX_RGB, /* name */ "Mix", - /* width+range */ 80, 60, 120, + /* width+range */ 110, 60, 120, /* class+opts */ NODE_CLASS_OP_COLOR, NODE_OPTIONS, /* input sock */ cmp_node_mix_rgb_in, /* output sock */ cmp_node_mix_rgb_out, @@ -2252,7 +2253,7 @@ static void node_composit_exec_setalpha(void *data, bNode *node, bNodeStack **in /* stack order in: col, alpha */ /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if(in[0]->data==NULL && in[1]->data==NULL) { out[0]->vec[0] = in[0]->vec[0]; out[0]->vec[1] = in[0]->vec[1]; out[0]->vec[2] = in[0]->vec[2]; @@ -2260,7 +2261,7 @@ static void node_composit_exec_setalpha(void *data, bNode *node, bNodeStack **in } else { /* make output size of input image */ - CompBuf *cbuf= in[0]->data; + CompBuf *cbuf= in[0]->data?in[0]->data:in[1]->data; CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ if(in[1]->data==NULL && in[1]->vec[0]==1.0f) { @@ -2349,12 +2350,12 @@ static void node_composit_exec_alphaover(void *data, bNode *node, bNodeStack **i return; /* input no image? then only color operation */ - if(in[1]->data==NULL) { + if(in[1]->data==NULL && in[2]->data==NULL) { do_alphaover_premul(node, out[0]->vec, in[1]->vec, in[2]->vec, in[0]->vec); } else { /* make output size of input image */ - CompBuf *cbuf= in[1]->data; + CompBuf *cbuf= in[1]->data?in[1]->data:in[2]->data; CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ if(node->custom1)