2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2006 Blender Foundation.
19
* All rights reserved.
21
* The Original Code is: all of this file.
23
* Contributor(s): none yet.
25
* ***** END GPL LICENSE BLOCK *****
28
/** \file blender/nodes/composite/nodes/node_composite_idMask.c
33
#include "node_composite_util.h"
36
/* **************** ID Mask ******************** */
38
static bNodeSocketTemplate cmp_node_idmask_in[]= {
39
{ SOCK_FLOAT, 1, "ID value", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
42
static bNodeSocketTemplate cmp_node_idmask_out[]= {
43
{ SOCK_FLOAT, 0, "Alpha"},
47
/* stackbuf should be zeroed */
48
static void do_idmask(CompBuf *stackbuf, CompBuf *cbuf, float idnr)
52
char *abuf= MEM_mapallocN(cbuf->x*cbuf->y, "anti ali buf");
55
for (x= cbuf->x*cbuf->y - 1; x>=0; x--)
59
antialias_tagbuf(cbuf->x, cbuf->y, abuf);
62
for (x= cbuf->x*cbuf->y - 1; x>=0; x--)
64
rect[x]= (1.0f/255.0f)*(float)abuf[x];
69
/* full sample version */
70
static void do_idmask_fsa(CompBuf *stackbuf, CompBuf *cbuf, float idnr)
77
for (x= cbuf->x*cbuf->y - 1; x>=0; x--)
84
static void node_composit_exec_idmask(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
88
if (out[0]->hasoutput==0)
92
CompBuf *cbuf= in[0]->data;
95
if (cbuf->type!=CB_VAL)
98
stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); /* allocs */;
100
if ((rd->scemode & R_FULL_SAMPLE) || node->custom2 == 0)
101
do_idmask_fsa(stackbuf, cbuf, (float)node->custom1);
103
do_idmask(stackbuf, cbuf, (float)node->custom1);
105
out[0]->data= stackbuf;
110
void register_node_type_cmp_idmask(bNodeTreeType *ttype)
112
static bNodeType ntype;
114
node_type_base(ttype, &ntype, CMP_NODE_ID_MASK, "ID Mask", NODE_CLASS_CONVERTOR, NODE_OPTIONS);
115
node_type_socket_templates(&ntype, cmp_node_idmask_in, cmp_node_idmask_out);
116
node_type_size(&ntype, 140, 100, 320);
117
node_type_exec(&ntype, node_composit_exec_idmask);
119
nodeRegisterType(ttype, &ntype);