2
* $Id: CMP_composite.c,v 1.4 2007/04/04 13:58:09 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"
34
/* **************** COMPOSITE ******************** */
35
static bNodeSocketType cmp_node_composite_in[]= {
36
{ SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
37
{ SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
38
{ SOCK_VALUE, 1, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
42
/* applies to render pipeline */
43
static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
45
/* image assigned to output */
46
/* stack order input sockets: col, alpha, z */
48
if(node->flag & NODE_DO_OUTPUT) { /* only one works on out */
50
if(rd->scemode & R_DOCOMP) {
51
RenderResult *rr= RE_GetResult(RE_GetRender(G.scene->id.name)); /* G.scene is WEAK! */
53
CompBuf *outbuf, *zbuf=NULL;
57
outbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 1);
60
composit1_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, do_copy_rgba, CB_RGBA);
62
composit2_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba, CB_RGBA, CB_VAL);
67
zbuf= alloc_compbuf(rr->rectx, rr->recty, CB_VAL, 1);
68
composit1_pixel_processor(node, zbuf, in[2]->data, in[2]->vec, do_copy_value, CB_VAL);
69
rr->rectz= zbuf->rect;
73
generate_preview(node, outbuf);
75
/* we give outbuf to rr... */
76
rr->rectf= outbuf->rect;
80
/* signal for imageviewer to refresh (it converts to byte rects...) */
81
BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
87
generate_preview(node, in[0]->data);
90
bNodeType cmp_node_composite= {
91
/* *next,*prev */ NULL, NULL,
92
/* type code */ CMP_NODE_COMPOSITE,
93
/* name */ "Composite",
94
/* width+range */ 80, 60, 200,
95
/* class+opts */ NODE_CLASS_OUTPUT, NODE_PREVIEW,
96
/* input sock */ cmp_node_composite_in,
97
/* output sock */ NULL,
99
/* execfunc */ node_composit_exec_composite,
102
/* freestoragefunc */ NULL,
103
/* copystoragefunc */ NULL,