Added "Blur factor" button in Vector Blur node, which scales the speed

vectors. It's actually shutter speed, but in this case works identical to
the old motionblur 'blur fac' button.

Note; the "Max Speed" button only clips speed, use this to prevent
extreme speed values. Max speed applied before the scaling happens.
This commit is contained in:
2006-02-07 11:39:26 +00:00
parent 682c1df9ec
commit 47054d00e6
8 changed files with 37 additions and 20 deletions

View File

@@ -39,6 +39,7 @@
#include "BPI_script.h"
#include "DNA_texture_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "RE_render_ext.h"
@@ -221,4 +222,4 @@ float *RE_RenderLayerGetPass(RenderLayer *rl, int passtype) {return NULL;}
float RE_filter_value(int type, float x) {return 0.0f;}
/* node_composite.c */
void zbuf_accumulate_vecblur(int samples, int maxspeed, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect) {}
void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect) {}

View File

@@ -779,7 +779,10 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
else if(type==CMP_NODE_BLUR)
node->storage= MEM_callocN(sizeof(NodeBlurData), "node blur data");
else if(type==CMP_NODE_VECBLUR) {
node->custom1= 32;
NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data");
node->storage= nbd;
nbd->samples= 32;
nbd->fac= 1.0f;
}
}

View File

@@ -2152,9 +2152,7 @@ static bNodeSocketType cmp_node_vecblur_out[]= {
static void node_composit_exec_vecblur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
extern void zbuf_accumulate_vecblur(int samples, int maxspeed, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect);
// NodeBlurData nbd;
NodeBlurData *nbd= node->storage;
CompBuf *new, *img= in[0]->data, *vecbuf= in[2]->data, *zbuf= in[1]->data;
if(img==NULL || vecbuf==NULL || zbuf==NULL || out[0]->hasoutput==0)
@@ -2176,13 +2174,10 @@ static void node_composit_exec_vecblur(void *data, bNode *node, bNodeStack **in,
return;
}
//new= alloc_compbuf(img->x, img->y, img->type, 1);
new= dupalloc_compbuf(img);
// do_filter3(vecbuf, vecbuf, soft, 1.0f);
/* call special zbuffer version */
zbuf_accumulate_vecblur(node->custom1, node->custom2, img->x, img->y, new->rect, img->rect, vecbuf->rect, zbuf->rect);
RE_zbuf_accumulate_vecblur(nbd, img->x, img->y, new->rect, img->rect, vecbuf->rect, zbuf->rect);
out[0]->data= new;
}
@@ -2195,7 +2190,7 @@ static bNodeType cmp_node_vecblur= {
/* class+opts */ NODE_CLASS_OPERATOR, NODE_OPTIONS,
/* input sock */ cmp_node_vecblur_in,
/* output sock */ cmp_node_vecblur_out,
/* storage */ "",
/* storage */ "NodeBlurData",
/* execfunc */ node_composit_exec_vecblur
};

View File

@@ -3610,6 +3610,15 @@ static void ntree_version_241(bNodeTree *ntree)
node->storage= nbd;
}
}
else if(node->type==CMP_NODE_VECBLUR) {
if(node->storage==NULL) {
NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch");
nbd->samples= node->custom1;
nbd->maxspeed= node->custom2;
nbd->fac= 1.0f;
node->storage= nbd;
}
}
}
}
}

View File

@@ -186,7 +186,8 @@ typedef struct NodeImageAnim {
} NodeImageAnim;
typedef struct NodeBlurData {
short sizex, sizey;
short sizex, sizey, samples, maxspeed;
float fac;
short filtertype;
char bokeh, gamma;
} NodeBlurData;

View File

@@ -36,6 +36,7 @@
struct Scene;
struct RenderData;
struct NodeBlurData;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* this include is what is exposed of render to outside world */
@@ -174,6 +175,8 @@ void RE_error_cb (struct Render *re, void (*f)(const char *str));
/* should move to kernel once... still unsure on how/where */
float RE_filter_value(int type, float x);
/* vector blur zbuffer method */
void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nbd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect);
#endif /* RE_PIPELINE_H */

View File

@@ -46,6 +46,7 @@
#include "DNA_lamp_types.h"
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_meshdata_types.h"
#include "BKE_global.h"
@@ -2062,14 +2063,14 @@ static void antialias_tagbuf(int xsize, int ysize, char *rectmove)
}
void zbuf_accumulate_vecblur(int samples, int maxspeed, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect)
void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect)
{
ZSpan zspan;
float jit[16][2];
float v1[3], v2[3], v3[3], v4[3], fx, fy;
float *rectdraw, *rectvz, *dvz, *dimg, *dvec1, *dvec2, *dz1, *dz2, *rectz;
float maxspeedsq= (float)maxspeed*maxspeed;
int y, x, step;
float maxspeedsq= (float)nbd->maxspeed*nbd->maxspeed;
int y, x, step, maxspeed= nbd->maxspeed, samples= nbd->samples;
char *rectmove, *dm;
zbuf_alloc_span(&zspan, xsize, ysize);
@@ -2214,7 +2215,7 @@ void zbuf_accumulate_vecblur(int samples, int maxspeed, int xsize, int ysize, fl
/* accumulate */
samples/= 2;
for(step= 1; step<=samples; step++) {
float speedfac= 0.5f*(float)step/(float)(samples+1);
float speedfac= 0.5f*nbd->fac*(float)step/(float)(samples+1);
float blendfac= 1.0f/(ABS(step)+1);
float mfac= 1.0f-blendfac;
int side, z= 4;

View File

@@ -798,18 +798,22 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node
static int node_composit_buts_vecblur(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
NodeBlurData *nbd= node->storage;
short dy= butr->ymin;
short dx= (butr->xmax-butr->xmin);
uiBlockBeginAlign(block);
uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Samples:",
butr->xmin, dy+19, dx, 19,
&node->custom1, 1, 256, 0, 0, "Amount of samples");
butr->xmin, dy+38, dx, 19,
&nbd->samples, 1, 256, 0, 0, "Amount of samples");
uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "MaxSpeed:",
butr->xmin, dy, dx, 19,
&node->custom2, 0, 1024, 0, 0, "If not zero, maximum speed in pixels");
butr->xmin, dy+19, dx, 19,
&nbd->maxspeed, 0, 1024, 0, 0, "If not zero, maximum speed in pixels");
uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "BlurFac:",
butr->xmin, dy, dx, 19,
&nbd->fac, 0.0f, 2.0f, 10, 2, "Scaling factor for motion vectors, actually 'shutter speed' in frames");
}
return 38;
return 57;
}
static int node_composit_buts_filter(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)