|
Blender
V2.59
|
00001 /* 00002 * $Id: CMP_composite.c 35237 2011-02-27 20:13:22Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2006 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #include "../CMP_util.h" 00036 00037 00038 00039 /* **************** COMPOSITE ******************** */ 00040 static bNodeSocketType cmp_node_composite_in[]= { 00041 { SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, 00042 { SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, 00043 { SOCK_VALUE, 1, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, 00044 { -1, 0, "" } 00045 }; 00046 00047 /* applies to render pipeline */ 00048 static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)) 00049 { 00050 /* image assigned to output */ 00051 /* stack order input sockets: col, alpha, z */ 00052 00053 if(node->flag & NODE_DO_OUTPUT) { /* only one works on out */ 00054 Scene *scene= (Scene *)node->id; 00055 RenderData *rd= data; 00056 00057 if(scene && (rd->scemode & R_DOCOMP)) { 00058 Render *re= RE_GetRender(scene->id.name); 00059 RenderResult *rr= RE_AcquireResultWrite(re); 00060 if(rr) { 00061 CompBuf *outbuf, *zbuf=NULL; 00062 00063 if(rr->rectf) 00064 MEM_freeN(rr->rectf); 00065 outbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 1); 00066 00067 if(in[1]->data==NULL) 00068 composit1_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, do_copy_rgba, CB_RGBA); 00069 else 00070 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); 00071 00072 if(in[2]->data) { 00073 if(rr->rectz) 00074 MEM_freeN(rr->rectz); 00075 zbuf= alloc_compbuf(rr->rectx, rr->recty, CB_VAL, 1); 00076 composit1_pixel_processor(node, zbuf, in[2]->data, in[2]->vec, do_copy_value, CB_VAL); 00077 rr->rectz= zbuf->rect; 00078 zbuf->malloc= 0; 00079 free_compbuf(zbuf); 00080 } 00081 generate_preview(data, node, outbuf); 00082 00083 /* we give outbuf to rr... */ 00084 rr->rectf= outbuf->rect; 00085 outbuf->malloc= 0; 00086 free_compbuf(outbuf); 00087 00088 /* signal for imageviewer to refresh (it converts to byte rects...) */ 00089 BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE); 00090 00091 RE_ReleaseResult(re); 00092 return; 00093 } 00094 else 00095 RE_ReleaseResult(re); 00096 } 00097 } 00098 if(in[0]->data) 00099 generate_preview(data, node, in[0]->data); 00100 } 00101 00102 void register_node_type_cmp_composite(ListBase *lb) 00103 { 00104 static bNodeType ntype; 00105 00106 node_type_base(&ntype, CMP_NODE_COMPOSITE, "Composite", NODE_CLASS_OUTPUT, NODE_PREVIEW, 00107 cmp_node_composite_in, NULL); 00108 node_type_size(&ntype, 80, 60, 200); 00109 node_type_exec(&ntype, node_composit_exec_composite); 00110 00111 nodeRegisterType(lb, &ntype); 00112 } 00113