? directional_blur_patch.txt ? projectfiles_vc7/blender/blender.ncb ? projectfiles_vc7/blender/blender.suo Index: source/blender/blenkernel/BKE_node.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/BKE_node.h,v retrieving revision 1.36 diff -u -r1.36 BKE_node.h --- source/blender/blenkernel/BKE_node.h 19 Jan 2007 12:43:01 -0000 1.36 +++ source/blender/blenkernel/BKE_node.h 28 Jan 2007 22:36:04 -0000 @@ -252,6 +252,7 @@ #define CMP_NODE_COMBHSVA 246 #define CMP_NODE_MATH 247 #define CMP_NODE_LUMA_MATTE 248 +#define CMP_NODE_DIRECTIONAL_BLUR 252 /* filter types */ Index: source/blender/blenkernel/intern/node_composite.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/node_composite.c,v retrieving revision 1.101 diff -u -r1.101 node_composite.c --- source/blender/blenkernel/intern/node_composite.c 19 Jan 2007 12:43:02 -0000 1.101 +++ source/blender/blenkernel/intern/node_composite.c 28 Jan 2007 22:35:50 -0000 @@ -5859,6 +5859,137 @@ /* execfunc */ node_composit_exec_math }; +/* **************** Directional Blur ******************** */ +static bNodeSocketType cmp_node_directionalBlur_in[]= { + { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 1, "Factor", 1, 0, 0, 0, 0, 500}, + { SOCK_VALUE, 1, "Angle", 50.0, 0.0, 0.0, 0.0, -500, 500}, + { -1, 0, "" } +}; + +static bNodeSocketType cmp_node_directionalBlur_out[]= { + { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static void node_composit_exec_directionalBlur(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + if(in[0]->data) + { + CompBuf *cbuf= in[0]->data; + CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); + int i, j, src_pix, src_width, src_height, srcydelt, x, y; + int dirx, diry; + int step; + + float sumR = 0.0f, sumG = 0.0f, sumB = 0.0f, blur_factor, size; + + double angle; + + float *srcpix, *srcdestpix, *outpix; + + src_pix= cbuf->type; + src_width= cbuf->x; + src_height= cbuf->y; + srcpix= cbuf->rect; + outpix= stackbuf->rect; + srcdestpix = outpix; + srcydelt= src_width*src_pix; + + step = (int)node->custom1; + if(step < 1) + { + step = 1; + } + + if(node->custom2) // If Bypass on + { + for(y=0; ydata= stackbuf; + } + else // If Bypass off + { + blur_factor = (int)(in[1]->vec[0]); + + if (blur_factor > 0) + { + angle = (int)(in[2]->vec[0]); + + for(y=0; yrect; + + dirx = (double)(x + j * cos ((2 * 3.1415) / (360 / angle))); + diry = (double)(y + j * sin ((2 * 3.1415) / (360 / angle))); + dirx = (dirx < 0) ? 0 : ((dirx >= src_width) ? src_width - 1 : dirx); + diry = (diry < 0) ? 0 : ((diry >= src_height) ? src_height - 1 : diry); + + srcpix += diry*srcydelt + dirx*src_pix; + + sumR += srcpix[0]; + sumG += srcpix[1]; + sumB += srcpix[2]; + } + + outpix= stackbuf->rect; + outpix += y*srcydelt + x*src_pix; + + outpix[0] = sumR / (size /(float)step); + outpix[1] = sumG / (size /(float)step); + outpix[2] = sumB / (size /(float)step); + + sumR = sumG = sumB = 0; + } + } + } + else + { + for(y=0; ydata= stackbuf; + } + } +} + +static bNodeType cmp_node_directionalBlur= { + /* type code */ CMP_NODE_DIRECTIONAL_BLUR, + /* name */ "Directional Blur", + /* width+range */ 140, 100, 320, + /* class+opts */ NODE_CLASS_OP_FILTER, NODE_OPTIONS, + /* input sock */ cmp_node_directionalBlur_in, + /* output sock */ cmp_node_directionalBlur_out, + /* storage */ "", + /* execfunc */ node_composit_exec_directionalBlur +}; + /* ****************** types array for all shaders ****************** */ bNodeType *node_all_composit[]= { @@ -5891,6 +6022,7 @@ &cmp_node_vecblur, &cmp_node_dilateerode, &cmp_node_defocus, + &cmp_node_directionalBlur, &cmp_node_valtorgb, &cmp_node_rgbtobw, Index: source/blender/src/drawnode.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawnode.c,v retrieving revision 1.61 diff -u -r1.61 drawnode.c --- source/blender/src/drawnode.c 14 Jan 2007 15:19:27 -0000 1.61 +++ source/blender/src/drawnode.c 28 Jan 2007 22:36:58 -0000 @@ -1504,6 +1504,21 @@ return 20; } +static int node_composit_buts_directionalBlur(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr) +{ + if(block) + { + uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Step: ", + butr->xmin, butr->ymin, 60, 20, + &node->custom1, 1, 50, 0, 0, "Level of sampling to compute the blur effect : 1 - Best"); + + uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "BP", + butr->xmax-25, butr->ymin, 25, 20, + &node->custom2, 0, 0, 0, 0, "Bypass : Node has no effect"); + } + return 30; +} + /* only once called */ static void node_composit_set_butfunc(bNodeType *ntype) { @@ -1605,6 +1620,9 @@ break; case CMP_NODE_MATH: ntype->butfunc= node_buts_math; + break; + case CMP_NODE_DIRECTIONAL_BLUR: + ntype->butfunc= node_composit_buts_directionalBlur; break; default: ntype->butfunc= NULL;