== Compositor ==

* Added patch 5251 X/Y Offset to Split Viewer node, by Juho
(with some modifications from the patch version).

Also various small tweaks to compositor drawing & buttons.
This commit is contained in:
2007-01-02 14:15:41 +00:00
parent 05338c7c1b
commit aa030ba90b
3 changed files with 92 additions and 31 deletions

View File

@@ -833,6 +833,10 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
iuser->sfra= 1;
iuser->fie_ima= 2;
iuser->ok= 1;
if(type==CMP_NODE_SPLITVIEWER){
node->custom1= 50; /* default 50% split */
}
}
else if(type==CMP_NODE_HUE_SAT) {
NodeHueSat *nhs= MEM_callocN(sizeof(NodeHueSat), "node hue sat");

View File

@@ -716,6 +716,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack *
ImBuf *ibuf;
CompBuf *cbuf, *buf1, *buf2, *mask;
int x, y;
float offset;
buf1= typecheck_compbuf(in[0]->data, CB_RGBA);
buf2= typecheck_compbuf(in[1]->data, CB_RGBA);
@@ -747,10 +748,31 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack *
/* mask buf */
mask= alloc_compbuf(buf1->x, buf1->y, CB_VAL, 1);
for(y=0; y<buf1->y; y++) {
float *fac= mask->rect + y*buf1->x;
for(x=buf1->x/2; x>0; x--, fac++)
*fac= 1.0f;
/* Check which offset mode is selected and limit offset if needed */
if(node->custom2 == 0) {
offset = buf1->x / 100.0f * node->custom1;
CLAMP(offset, 0, buf1->x);
}
else {
offset = buf1->y / 100.0f * node->custom1;
CLAMP(offset, 0, buf1->y);
}
if(node->custom2 == 0) {
for(y=0; y<buf1->y; y++) {
float *fac= mask->rect + y*buf1->x;
for(x=offset; x>0; x--, fac++)
*fac= 1.0f;
}
}
else {
for(y=0; y<offset; y++) {
float *fac= mask->rect + y*buf1->x;
for(x=buf1->x; x>0; x--, fac++)
*fac= 1.0f;
}
}
composit3_pixel_processor(node, cbuf, buf1, in[0]->vec, buf2, in[1]->vec, mask, NULL, do_copy_split_rgba, CB_RGBA, CB_RGBA, CB_VAL);
@@ -769,8 +791,8 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack *
static bNodeType cmp_node_splitviewer= {
/* type code */ CMP_NODE_SPLITVIEWER,
/* name */ "SplitViewer",
/* width+range */ 80, 60, 200,
/* class+opts */ NODE_CLASS_OUTPUT, NODE_PREVIEW,
/* width+range */ 140, 100, 320,
/* class+opts */ NODE_CLASS_OUTPUT, NODE_PREVIEW|NODE_OPTIONS,
/* input sock */ cmp_node_splitviewer_in,
/* output sock */ NULL,
/* storage */ "ImageUser",

View File

@@ -982,21 +982,21 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node
if(block) {
NodeBlurData *nbd= node->storage;
uiBut *bt;
short dy= butr->ymin+19;
short dy= butr->ymin+38;
short dx= (butr->xmax-butr->xmin)/2;
short dx3=(butr->xmax-butr->xmin)/3;
char str[256];
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);
uiDefButS(block, MENU, B_NODE_EXEC+node->nr,str,
butr->xmin, dy, dx3, 19,
butr->xmin, dy, dx*2, 19,
&nbd->filtertype, 0, 0, 0, 0, "Set sampling filter for blur");
dy-=19;
uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Bokeh",
butr->xmin+dx3, dy, dx3, 19,
butr->xmin, dy, dx, 19,
&nbd->bokeh, 0, 0, 0, 0, "Uses circular filter, warning it's slow!");
uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Gamma",
butr->xmin+2*dx3, dy, dx3, 19,
butr->xmin+dx, dy, dx, 19,
&nbd->gamma, 0, 0, 0, 0, "Applies filter on gamma corrected values");
dy-=19;
@@ -1007,7 +1007,7 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node
butr->xmin+dx, dy, dx, 19,
&nbd->sizey, 0, 256, 0, 0, "");
}
return 38;
return 57;
}
/* qdn: defocus node */
@@ -1116,6 +1116,24 @@ static int node_composit_buts_flip(uiBlock *block, bNodeTree *ntree, bNode *node
return 20;
}
static int node_composit_buts_splitviewer(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
uiBlockBeginAlign(block);
uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "X",
butr->xmin, butr->ymin+19, (butr->xmax-butr->xmin)/2, 20,
&node->custom2, 0.0, 0.0, 0, 0, "");
uiDefButS(block, ROW, B_NODE_EXEC+node->nr, "Y",
butr->xmin+(butr->xmax-butr->xmin)/2, butr->ymin+19, (butr->xmax-butr->xmin)/2, 20,
&node->custom2, 0.0, 1.0, 0, 0, "");
uiDefButS(block, NUMSLI, B_NODE_EXEC+node->nr, "Split %: ",
butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, &node->custom1, 0, 100, 10, 0, "");
}
return 40;
}
static int node_composit_buts_map_value(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
@@ -1482,6 +1500,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_FLIP:
ntype->butfunc= node_composit_buts_flip;
break;
case CMP_NODE_SPLITVIEWER:
ntype->butfunc= node_composit_buts_splitviewer;
break;
case CMP_NODE_MIX_RGB:
ntype->butfunc= node_buts_mix_rgb;
break;
@@ -1728,27 +1749,38 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
{
float xscale= (prv->xmax-prv->xmin)/((float)preview->xsize);
float yscale= (prv->ymax-prv->ymin)/((float)preview->ysize);
float centx= prv->xmin + 0.5*(prv->xmax-prv->xmin);
float centy= prv->ymin + 0.5*(prv->ymax-prv->ymin);
float tile= (prv->xmax - prv->xmin) / 10.0;
float x, y;
/* draw standard bacdrop to show alpha */
glBegin(GL_TRIANGLES);
glColor3f(0.625f, 0.625f, 0.625f);
glVertex2f(prv->xmin, prv->ymin);
glVertex2f(prv->xmax, prv->ymin);
glVertex2f(centx, centy);
glVertex2f(prv->xmin, prv->ymax);
glVertex2f(prv->xmax, prv->ymax);
glVertex2f(centx, centy);
/* draw checkerboard backdrop to show alpha */
glColor3ub(120, 120, 120);
glRectf(prv->xmin, prv->ymin, prv->xmax, prv->ymax);
glColor3ub(160, 160, 160);
glColor3f(0.25f, 0.25f, 0.25f);
glVertex2f(prv->xmin, prv->ymin);
glVertex2f(prv->xmin, prv->ymax);
glVertex2f(centx, centy);
glVertex2f(prv->xmax, prv->ymin);
glVertex2f(prv->xmax, prv->ymax);
glVertex2f(centx, centy);
glEnd();
for(y=prv->ymin; y<prv->ymax; y+=tile*2) {
for(x=prv->xmin; x<prv->xmax; x+=tile*2) {
float tilex= tile, tiley= tile;
if(x+tile > prv->xmax)
tilex= prv->xmax-x;
if(y+tile > prv->ymax)
tiley= prv->ymax-y;
glRectf(x, y, x + tilex, y + tiley);
}
}
for(y=prv->ymin+tile; y<prv->ymax; y+=tile*2) {
for(x=prv->xmin+tile; x<prv->xmax; x+=tile*2) {
float tilex= tile, tiley= tile;
if(x+tile > prv->xmax)
tilex= prv->xmax-x;
if(y+tile > prv->ymax)
tiley= prv->ymax-y;
glRectf(x, y, x + tilex, y + tiley);
}
}
glPixelZoom(xscale, yscale);
glEnable(GL_BLEND);
@@ -1759,6 +1791,9 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glDisable(GL_BLEND);
glPixelZoom(1.0f, 1.0f);
BIF_ThemeColorShadeAlpha(TH_BACK, -15, +100);
fdrawbox(prv->xmin, prv->ymin, prv->xmax, prv->ymax);
}