|
Blender
V2.59
|
00001 /* 00002 * $Id: CMP_vecBlur.c 36276 2011-04-21 15:53:30Z campbellbarton $ 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 /* **************** VECTOR BLUR ******************** */ 00039 static bNodeSocketType cmp_node_vecblur_in[]= { 00040 { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, 00041 { SOCK_VALUE, 1, "Z", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, 00042 { SOCK_VECTOR, 1, "Speed", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, 00043 { -1, 0, "" } 00044 }; 00045 static bNodeSocketType cmp_node_vecblur_out[]= { 00046 { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, 00047 { -1, 0, "" } 00048 }; 00049 00050 00051 00052 static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) 00053 { 00054 NodeBlurData *nbd= node->storage; 00055 CompBuf *new, *img= in[0]->data, *vecbuf= in[2]->data, *zbuf= in[1]->data; 00056 00057 if(img==NULL || vecbuf==NULL || zbuf==NULL || out[0]->hasoutput==0) 00058 return; 00059 if(vecbuf->x!=img->x || vecbuf->y!=img->y) { 00060 printf("ERROR: cannot do different sized vecbuf yet\n"); 00061 return; 00062 } 00063 if(vecbuf->type!=CB_VEC4) { 00064 printf("ERROR: input should be vecbuf\n"); 00065 return; 00066 } 00067 if(zbuf->type!=CB_VAL) { 00068 printf("ERROR: input should be zbuf\n"); 00069 return; 00070 } 00071 if(zbuf->x!=img->x || zbuf->y!=img->y) { 00072 printf("ERROR: cannot do different sized zbuf yet\n"); 00073 return; 00074 } 00075 00076 /* allow the input image to be of another type */ 00077 img= typecheck_compbuf(in[0]->data, CB_RGBA); 00078 00079 new= dupalloc_compbuf(img); 00080 00081 /* call special zbuffer version */ 00082 RE_zbuf_accumulate_vecblur(nbd, img->x, img->y, new->rect, img->rect, vecbuf->rect, zbuf->rect); 00083 00084 out[0]->data= new; 00085 00086 if(img!=in[0]->data) 00087 free_compbuf(img); 00088 } 00089 00090 static void node_composit_init_vecblur(bNode* node) 00091 { 00092 NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data"); 00093 node->storage= nbd; 00094 nbd->samples= 32; 00095 nbd->fac= 1.0f; 00096 } 00097 00098 /* custom1: itterations, custom2: maxspeed (0 = nolimit) */ 00099 void register_node_type_cmp_vecblur(ListBase *lb) 00100 { 00101 static bNodeType ntype; 00102 00103 node_type_base(&ntype, CMP_NODE_VECBLUR, "Vector Blur", NODE_CLASS_OP_FILTER, NODE_OPTIONS, 00104 cmp_node_vecblur_in, cmp_node_vecblur_out); 00105 node_type_size(&ntype, 120, 80, 200); 00106 node_type_init(&ntype, node_composit_init_vecblur); 00107 node_type_storage(&ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage); 00108 node_type_exec(&ntype, node_composit_exec_vecblur); 00109 00110 nodeRegisterType(lb, &ntype); 00111 } 00112 00113