Compositor: Added a basic "Time Node".
Just indicate start/end frame, and node outputs with Curve a value between 0.0 and 1.0.
This commit is contained in:
@@ -769,6 +769,11 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
|
|||||||
node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
|
node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
|
||||||
else if(type==CMP_NODE_CURVE_RGB)
|
else if(type==CMP_NODE_CURVE_RGB)
|
||||||
node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
|
node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
else if(type==CMP_NODE_TIME) {
|
||||||
|
node->custom1= G.scene->r.sfra;
|
||||||
|
node->custom2= G.scene->r.efra;
|
||||||
|
node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
else if(type==CMP_NODE_MAP_VALUE)
|
else if(type==CMP_NODE_MAP_VALUE)
|
||||||
node->storage= add_mapping();
|
node->storage= add_mapping();
|
||||||
else if(type==CMP_NODE_BLUR)
|
else if(type==CMP_NODE_BLUR)
|
||||||
@@ -927,7 +932,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
|
|||||||
MEM_freeN(node->storage);
|
MEM_freeN(node->storage);
|
||||||
}
|
}
|
||||||
else if(ntree->type==NTREE_COMPOSIT) {
|
else if(ntree->type==NTREE_COMPOSIT) {
|
||||||
if(node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB)
|
if(ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB))
|
||||||
curvemapping_free(node->storage);
|
curvemapping_free(node->storage);
|
||||||
else
|
else
|
||||||
MEM_freeN(node->storage);
|
MEM_freeN(node->storage);
|
||||||
|
|||||||
@@ -950,6 +950,36 @@ static bNodeType cmp_node_normal= {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* **************** CURVE Time ******************** */
|
||||||
|
|
||||||
|
/* custom1 = sfra, custom2 = efra */
|
||||||
|
static bNodeSocketType cmp_node_time_out[]= {
|
||||||
|
{ SOCK_VALUE, 0, "Fac", 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f},
|
||||||
|
{ -1, 0, "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void node_composit_exec_time(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||||
|
{
|
||||||
|
/* stack order output: fac */
|
||||||
|
float fac= 0.0f;
|
||||||
|
|
||||||
|
if(node->custom1 < node->custom2)
|
||||||
|
fac= (G.scene->r.cfra - node->custom1)/(float)(node->custom2-node->custom1);
|
||||||
|
|
||||||
|
out[0]->vec[0]= curvemapping_evaluateF(node->storage, 0, fac);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bNodeType cmp_node_time= {
|
||||||
|
/* type code */ CMP_NODE_TIME,
|
||||||
|
/* name */ "Time",
|
||||||
|
/* width+range */ 140, 100, 320,
|
||||||
|
/* class+opts */ NODE_CLASS_GENERATOR, NODE_OPTIONS,
|
||||||
|
/* input sock */ NULL,
|
||||||
|
/* output sock */ cmp_node_time_out,
|
||||||
|
/* storage */ "CurveMapping",
|
||||||
|
/* execfunc */ node_composit_exec_time
|
||||||
|
};
|
||||||
|
|
||||||
/* **************** CURVE VEC ******************** */
|
/* **************** CURVE VEC ******************** */
|
||||||
static bNodeSocketType cmp_node_curve_vec_in[]= {
|
static bNodeSocketType cmp_node_curve_vec_in[]= {
|
||||||
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
|
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
|
||||||
@@ -2184,6 +2214,7 @@ bNodeType *node_all_composit[]= {
|
|||||||
&cmp_node_normal,
|
&cmp_node_normal,
|
||||||
&cmp_node_curve_vec,
|
&cmp_node_curve_vec,
|
||||||
&cmp_node_curve_rgb,
|
&cmp_node_curve_rgb,
|
||||||
|
&cmp_node_time,
|
||||||
&cmp_node_image,
|
&cmp_node_image,
|
||||||
&cmp_node_rresult,
|
&cmp_node_rresult,
|
||||||
&cmp_node_alphaover,
|
&cmp_node_alphaover,
|
||||||
@@ -2222,5 +2253,7 @@ void ntreeCompositTagAnimated(bNodeTree *ntree)
|
|||||||
if(node->storage)
|
if(node->storage)
|
||||||
NodeTagChanged(ntree, node);
|
NodeTagChanged(ntree, node);
|
||||||
}
|
}
|
||||||
|
else if(node->type==CMP_NODE_TIME)
|
||||||
|
NodeTagChanged(ntree, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1267,10 +1267,10 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
|
|||||||
node->storage= newdataadr(fd, node->storage);
|
node->storage= newdataadr(fd, node->storage);
|
||||||
if(node->storage) {
|
if(node->storage) {
|
||||||
|
|
||||||
/* could be handlerized at some point, now only 1 exception still */
|
/* could be handlerized at some point */
|
||||||
if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
|
if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
|
||||||
direct_link_curvemapping(fd, node->storage);
|
direct_link_curvemapping(fd, node->storage);
|
||||||
else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB))
|
else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_TIME || node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB))
|
||||||
direct_link_curvemapping(fd, node->storage);
|
direct_link_curvemapping(fd, node->storage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
|
|||||||
/* could be handlerized at some point, now only 1 exception still */
|
/* could be handlerized at some point, now only 1 exception still */
|
||||||
if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
|
if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
|
||||||
write_curvemapping(wd, node->storage);
|
write_curvemapping(wd, node->storage);
|
||||||
else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB))
|
else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_TIME || node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB))
|
||||||
write_curvemapping(wd, node->storage);
|
write_curvemapping(wd, node->storage);
|
||||||
else
|
else
|
||||||
writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
|
writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
|
||||||
|
|||||||
@@ -774,13 +774,13 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node
|
|||||||
|
|
||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
sprintf(str, "Filter Type%%t|Flat %%x%d|Tent %%x%d|Quad %%x%d|Cubic %%x%d|Gauss %%x%d|CatRom %%x%d|Mitch %%x%d", R_FILTER_BOX, R_FILTER_TENT, R_FILTER_QUAD, R_FILTER_CUBIC, R_FILTER_GAUSS, R_FILTER_CATROM, R_FILTER_MITCH);
|
sprintf(str, "Filter Type%%t|Flat %%x%d|Tent %%x%d|Quad %%x%d|Cubic %%x%d|Gauss %%x%d|CatRom %%x%d|Mitch %%x%d", R_FILTER_BOX, R_FILTER_TENT, R_FILTER_QUAD, R_FILTER_CUBIC, R_FILTER_GAUSS, R_FILTER_CATROM, R_FILTER_MITCH);
|
||||||
uiDefButS(block, MENU, B_NODE_EXEC,str,
|
uiDefButS(block, MENU, B_NODE_EXEC+node->nr,str,
|
||||||
butr->xmin, dy, dx3, 19,
|
butr->xmin, dy, dx3, 19,
|
||||||
&nbd->filtertype, 0, 0, 0, 0, "Set sampling filter for blur");
|
&nbd->filtertype, 0, 0, 0, 0, "Set sampling filter for blur");
|
||||||
uiDefButC(block, TOG, B_NODE_EXEC, "Bokeh",
|
uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Bokeh",
|
||||||
butr->xmin+dx3, dy, dx3, 19,
|
butr->xmin+dx3, dy, dx3, 19,
|
||||||
&nbd->bokeh, 0, 0, 0, 0, "Uses circular filter, warning it's slow!");
|
&nbd->bokeh, 0, 0, 0, 0, "Uses circular filter, warning it's slow!");
|
||||||
uiDefButC(block, TOG, B_NODE_EXEC, "Gamma",
|
uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Gamma",
|
||||||
butr->xmin+2*dx3, dy, dx3, 19,
|
butr->xmin+2*dx3, dy, dx3, 19,
|
||||||
&nbd->gamma, 0, 0, 0, 0, "Applies filter on gamma corrected values");
|
&nbd->gamma, 0, 0, 0, 0, "Applies filter on gamma corrected values");
|
||||||
|
|
||||||
@@ -832,6 +832,28 @@ static int node_composit_buts_map_value(uiBlock *block, bNodeTree *ntree, bNode
|
|||||||
return 80;
|
return 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int node_composit_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
|
||||||
|
{
|
||||||
|
if(block) {
|
||||||
|
short dx= (butr->xmax-butr->xmin)/2;
|
||||||
|
|
||||||
|
uiDefBut(block, BUT_CURVE, B_NODE_EXEC+node->nr, "",
|
||||||
|
butr->xmin, butr->ymin+24, butr->xmax-butr->xmin, butr->ymax-butr->ymin-24,
|
||||||
|
node->storage, 0.0f, 1.0f, 0, 0, "");
|
||||||
|
|
||||||
|
uiBlockBeginAlign(block);
|
||||||
|
uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Sta:",
|
||||||
|
butr->xmin, butr->ymin, dx, 19,
|
||||||
|
&node->custom1, 1.0, 20000.0, 0, 0, "Start frame");
|
||||||
|
uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "End:",
|
||||||
|
butr->xmin+dx, butr->ymin, dx, 19,
|
||||||
|
&node->custom2, 1.0, 20000.0, 0, 0, "End frame");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return node->width-NODE_DY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* only once called */
|
/* only once called */
|
||||||
static void node_composit_set_butfunc(bNodeType *ntype)
|
static void node_composit_set_butfunc(bNodeType *ntype)
|
||||||
@@ -876,6 +898,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
|
|||||||
case CMP_NODE_MAP_VALUE:
|
case CMP_NODE_MAP_VALUE:
|
||||||
ntype->butfunc= node_composit_buts_map_value;
|
ntype->butfunc= node_composit_buts_map_value;
|
||||||
break;
|
break;
|
||||||
|
case CMP_NODE_TIME:
|
||||||
|
ntype->butfunc= node_composit_buts_time;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ntype->butfunc= NULL;
|
ntype->butfunc= NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1186,7 +1186,7 @@ static void node_add_menu(SpaceNode *snode)
|
|||||||
}
|
}
|
||||||
else if(snode->treetype==NTREE_COMPOSIT) {
|
else if(snode->treetype==NTREE_COMPOSIT) {
|
||||||
/* compo menu, still hardcoded defines... solve */
|
/* compo menu, still hardcoded defines... solve */
|
||||||
event= pupmenu("Add Node%t|Render Result %x221|Composite %x222|Viewer%x201|Image %x220|RGB Curves%x209|AlphaOver %x210|Blur %x211|Vector Blur %x215|Filter %x212|Value %x203|Color %x202|Mix %x204|ColorRamp %x205|Color to BW %x206|Map Value %x213|Normal %x207");
|
event= pupmenu("Add Node%t|Render Result %x221|Composite %x222|Viewer%x201|Image %x220|RGB Curves%x209|AlphaOver %x210|Blur %x211|Vector Blur %x215|Filter %x212|Value %x203|Color %x202|Mix %x204|ColorRamp %x205|Color to BW %x206|Map Value %x213|Time %x214|Normal %x207");
|
||||||
if(event<1) return;
|
if(event<1) return;
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|||||||
Reference in New Issue
Block a user