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