2
* $Id: CMP_lummaMatte.c,v 1.4 2007/04/04 13:58:10 jesterking Exp $
4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* The Original Code is Copyright (C) 2006 Blender Foundation.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): none yet.
27
* ***** END GPL LICENSE BLOCK *****
30
#include "../CMP_util.h"
33
/* ******************* Luma Matte Node ********************************* */
34
static bNodeSocketType cmp_node_luma_matte_in[]={
35
{SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
39
static bNodeSocketType cmp_node_luma_matte_out[]={
40
{SOCK_RGBA,0,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
41
{SOCK_VALUE,0,"Matte",0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
45
static void do_luma_matte(bNode *node, float *out, float *in)
47
NodeChroma *c=(NodeChroma *)node->storage;
60
alpha=(in[0]-c->t2)/(c->t1-c->t2);
63
/* don't make something that was more transparent less transparent */
73
static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
78
if(in[0]->hasinput==0) return;
79
if(in[0]->data==NULL) return;
80
if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return;
82
cbuf=typecheck_compbuf(in[0]->data, CB_RGBA);
84
outbuf=dupalloc_compbuf(cbuf);
86
composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_yuva, CB_RGBA);
87
composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_luma_matte, CB_RGBA);
88
composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_yuva_to_rgba, CB_RGBA);
90
generate_preview(node, outbuf);
92
if (out[1]->hasoutput)
93
out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A);
98
static void node_composit_init_luma_matte(bNode *node)
100
NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma");
106
bNodeType cmp_node_luma_matte={
107
/* *next,*prev */ NULL, NULL,
108
/* type code */ CMP_NODE_LUMA_MATTE,
109
/* name */ "Luminance Key",
110
/* width+range */ 200, 80, 250,
111
/* class+opts */ NODE_CLASS_MATTE, NODE_PREVIEW|NODE_OPTIONS,
112
/* input sock */ cmp_node_luma_matte_in,
113
/* output sock */ cmp_node_luma_matte_out,
114
/* storage */ "NodeChroma",
115
/* execfunc */ node_composit_exec_luma_matte,
117
/* initfunc */ node_composit_init_luma_matte,
118
/* freestoragefunc */ node_free_standard_storage,
119
/* copystoragefunc */ node_copy_standard_storage,