2
* $Id: CMP_sepcombRGBA.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"
32
/* **************** SEPARATE RGBA ******************** */
33
static bNodeSocketType cmp_node_seprgba_in[]= {
34
{ SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
37
static bNodeSocketType cmp_node_seprgba_out[]= {
38
{ SOCK_VALUE, 0, "R", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
39
{ SOCK_VALUE, 0, "G", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
40
{ SOCK_VALUE, 0, "B", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
41
{ SOCK_VALUE, 0, "A", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
45
static void node_composit_exec_seprgba(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
47
/* stack order out: bw channels */
48
/* stack order in: col */
50
/* input no image? then only color operation */
51
if(in[0]->data==NULL) {
52
out[0]->vec[0] = in[0]->vec[0];
53
out[1]->vec[0] = in[0]->vec[1];
54
out[2]->vec[0] = in[0]->vec[2];
55
out[3]->vec[0] = in[0]->vec[3];
58
/* make sure we get right rgba buffer */
59
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
61
/* don't do any pixel processing, just copy the stack directly (faster, I presume) */
63
out[0]->data= valbuf_from_rgbabuf(cbuf, CHAN_R);
65
out[1]->data= valbuf_from_rgbabuf(cbuf, CHAN_G);
67
out[2]->data= valbuf_from_rgbabuf(cbuf, CHAN_B);
69
out[3]->data= valbuf_from_rgbabuf(cbuf, CHAN_A);
77
bNodeType cmp_node_seprgba= {
78
/* *next,*prev */ NULL, NULL,
79
/* type code */ CMP_NODE_SEPRGBA,
80
/* name */ "Separate RGBA",
81
/* width+range */ 80, 40, 140,
82
/* class+opts */ NODE_CLASS_CONVERTOR, 0,
83
/* input sock */ cmp_node_seprgba_in,
84
/* output sock */ cmp_node_seprgba_out,
86
/* execfunc */ node_composit_exec_seprgba,
89
/* freestoragefunc */ NULL,
90
/* copystoragefunc */ NULL,
96
/* **************** COMBINE RGBA ******************** */
97
static bNodeSocketType cmp_node_combrgba_in[]= {
98
{ SOCK_VALUE, 1, "R", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
99
{ SOCK_VALUE, 1, "G", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
100
{ SOCK_VALUE, 1, "B", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
101
{ SOCK_VALUE, 1, "A", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
104
static bNodeSocketType cmp_node_combrgba_out[]= {
105
{ SOCK_RGBA, 0, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
109
static void do_combrgba(bNode *node, float *out, float *in1, float *in2, float *in3, float *in4)
117
static void node_composit_exec_combrgba(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
119
/* stack order out: 1 rgba channels */
120
/* stack order in: 4 value channels */
122
/* input no image? then only color operation */
123
if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) {
124
out[0]->vec[0] = in[0]->vec[0];
125
out[0]->vec[1] = in[1]->vec[0];
126
out[0]->vec[2] = in[2]->vec[0];
127
out[0]->vec[3] = in[3]->vec[0];
130
/* make output size of first available input image */
134
/* allocate a CompBuf the size of the first available input */
135
if (in[0]->data) cbuf = in[0]->data;
136
else if (in[1]->data) cbuf = in[1]->data;
137
else if (in[2]->data) cbuf = in[2]->data;
138
else cbuf = in[3]->data;
140
stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
142
composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec,
143
in[2]->data, in[2]->vec, in[3]->data, in[3]->vec,
144
do_combrgba, CB_VAL, CB_VAL, CB_VAL, CB_VAL);
146
out[0]->data= stackbuf;
150
bNodeType cmp_node_combrgba= {
151
/* *next,*prev */ NULL, NULL,
152
/* type code */ CMP_NODE_COMBRGBA,
153
/* name */ "Combine RGBA",
154
/* width+range */ 80, 40, 140,
155
/* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS,
156
/* input sock */ cmp_node_combrgba_in,
157
/* output sock */ cmp_node_combrgba_out,
159
/* execfunc */ node_composit_exec_combrgba,
162
/* freestoragefunc */ NULL,
163
/* copystoragefunc */ NULL,