Experiment with the compositor border in editor
Preserve buffer form previous runs so it's possible to make a compo of full frame, then draw a border and start tweaking nodes and see updates in that border. Main idea is to make it able to visually compare difference between what was changed inside the border and how frame looked before the tweaks outside of the border. Also implemented Clear Viewer Border in compositor, shortcut it Ctrl-Alt-B. Reviewers: lukastoenne, jbakker CC: venomgfx, sebastian_k Differential Revision: https://developer.blender.org/D582
This commit is contained in:
@@ -222,5 +222,7 @@ void glaDrawImBuf_glsl(struct ImBuf *ibuf, float x, float y, int zoomfilter,
|
||||
/* Draw imbuf on a screen, preferably using GLSL display transform */
|
||||
void glaDrawImBuf_glsl_ctx(const struct bContext *C, struct ImBuf *ibuf, float x, float y, int zoomfilter);
|
||||
|
||||
void glaDrawBorderCorners(const struct rcti *border, float zoomx, float zoomy);
|
||||
|
||||
#endif /* __BIF_GLUTIL_H__ */
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
#include "IMB_colormanagement.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#ifndef GL_CLAMP_TO_EDGE
|
||||
#define GL_CLAMP_TO_EDGE 0x812F
|
||||
#endif
|
||||
@@ -1139,3 +1141,40 @@ void cpack(unsigned int x)
|
||||
(((x) >> 8) & 0xFF),
|
||||
(((x) >> 16) & 0xFF) );
|
||||
}
|
||||
|
||||
void glaDrawBorderCorners(const rcti *border, float zoomx, float zoomy)
|
||||
{
|
||||
float delta_x = 4.0f * UI_DPI_FAC / zoomx;
|
||||
float delta_y = 4.0f * UI_DPI_FAC / zoomy;
|
||||
|
||||
delta_x = min_ff(delta_x, border->xmax - border->xmin);
|
||||
delta_y = min_ff(delta_y, border->ymax - border->ymin);
|
||||
|
||||
/* left bottom corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(border->xmin, border->ymin + delta_y);
|
||||
glVertex2f(border->xmin, border->ymin);
|
||||
glVertex2f(border->xmin + delta_x, border->ymin);
|
||||
glEnd();
|
||||
|
||||
/* left top corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(border->xmin, border->ymax - delta_y);
|
||||
glVertex2f(border->xmin, border->ymax);
|
||||
glVertex2f(border->xmin + delta_x, border->ymax);
|
||||
glEnd();
|
||||
|
||||
/* right bottom corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(border->xmax - delta_x, border->ymin);
|
||||
glVertex2f(border->xmax, border->ymin);
|
||||
glVertex2f(border->xmax, border->ymin + delta_y);
|
||||
glEnd();
|
||||
|
||||
/* right top corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(border->xmax - delta_x, border->ymax);
|
||||
glVertex2f(border->xmax, border->ymax);
|
||||
glVertex2f(border->xmax, border->ymax - delta_y);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -119,39 +119,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx,
|
||||
UI_ThemeColor(TH_FACE_SELECT);
|
||||
|
||||
for (i = 0, tile = tiles; i < total_tiles; i++, tile++) {
|
||||
float delta_x = 4.0f * UI_DPI_FAC / zoomx;
|
||||
float delta_y = 4.0f * UI_DPI_FAC / zoomy;
|
||||
|
||||
delta_x = min_ff(delta_x, tile->xmax - tile->xmin);
|
||||
delta_y = min_ff(delta_y, tile->ymax - tile->ymin);
|
||||
|
||||
/* left bottom corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(tile->xmin, tile->ymin + delta_y);
|
||||
glVertex2f(tile->xmin, tile->ymin);
|
||||
glVertex2f(tile->xmin + delta_x, tile->ymin);
|
||||
glEnd();
|
||||
|
||||
/* left top corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(tile->xmin, tile->ymax - delta_y);
|
||||
glVertex2f(tile->xmin, tile->ymax);
|
||||
glVertex2f(tile->xmin + delta_x, tile->ymax);
|
||||
glEnd();
|
||||
|
||||
/* right bottom corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(tile->xmax - delta_x, tile->ymin);
|
||||
glVertex2f(tile->xmax, tile->ymin);
|
||||
glVertex2f(tile->xmax, tile->ymin + delta_y);
|
||||
glEnd();
|
||||
|
||||
/* right top corner */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(tile->xmax - delta_x, tile->ymax);
|
||||
glVertex2f(tile->xmax, tile->ymax);
|
||||
glVertex2f(tile->xmax, tile->ymax - delta_y);
|
||||
glEnd();
|
||||
glaDrawBorderCorners(tile, zoomx, zoomy);
|
||||
}
|
||||
|
||||
MEM_freeN(tiles);
|
||||
|
||||
@@ -3122,20 +3122,17 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
||||
}
|
||||
|
||||
if ((snode->nodetree->flag & NTREE_VIEWER_BORDER) &&
|
||||
viewer_border->xmin < viewer_border->xmax &&
|
||||
viewer_border->ymin < viewer_border->ymax)
|
||||
viewer_border->xmin < viewer_border->xmax &&
|
||||
viewer_border->ymin < viewer_border->ymax)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
setlinestyle(3);
|
||||
cpack(0x4040FF);
|
||||
|
||||
glRectf(x + snode->zoom * viewer_border->xmin * ibuf->x,
|
||||
y + snode->zoom * viewer_border->ymin * ibuf->y,
|
||||
x + snode->zoom * viewer_border->xmax * ibuf->x,
|
||||
y + snode->zoom * viewer_border->ymax * ibuf->y);
|
||||
|
||||
setlinestyle(0);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
rcti pixel_border;
|
||||
UI_ThemeColor(TH_ACTIVE);
|
||||
BLI_rcti_init(&pixel_border,
|
||||
x + snode->zoom * viewer_border->xmin * ibuf->x,
|
||||
x + snode->zoom * viewer_border->xmax * ibuf->x,
|
||||
y + snode->zoom * viewer_border->ymin * ibuf->y,
|
||||
y + snode->zoom * viewer_border->ymax * ibuf->y);
|
||||
glaDrawBorderCorners(&pixel_border, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2482,14 +2482,6 @@ static int viewer_border_exec(bContext *C, wmOperator *op)
|
||||
btree->flag &= ~NTREE_VIEWER_BORDER;
|
||||
}
|
||||
else {
|
||||
if (ibuf->rect)
|
||||
memset(ibuf->rect, 0, 4 * ibuf->x * ibuf->y);
|
||||
|
||||
if (ibuf->rect_float)
|
||||
memset(ibuf->rect_float, 0, 4 * ibuf->x * ibuf->y * sizeof(float));
|
||||
|
||||
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
||||
|
||||
btree->flag |= NTREE_VIEWER_BORDER;
|
||||
}
|
||||
|
||||
@@ -2526,3 +2518,30 @@ void NODE_OT_viewer_border(wmOperatorType *ot)
|
||||
/* properties */
|
||||
WM_operator_properties_gesture_border(ot, true);
|
||||
}
|
||||
|
||||
static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNodeTree *btree = snode->nodetree;
|
||||
|
||||
btree->flag &= ~NTREE_VIEWER_BORDER;
|
||||
snode_notify(C, snode);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void NODE_OT_clear_viewer_border(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Clear Viewer Border";
|
||||
ot->description = "Clear the boundaries for viewer operations";
|
||||
ot->idname = "NODE_OT_clear_viewer_border";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = clear_viewer_border_exec;
|
||||
ot->poll = composite_node_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
@@ -217,6 +217,7 @@ void NODE_OT_tree_socket_move(struct wmOperatorType *ot);
|
||||
void NODE_OT_shader_script_update(struct wmOperatorType *ot);
|
||||
|
||||
void NODE_OT_viewer_border(struct wmOperatorType *ot);
|
||||
void NODE_OT_clear_viewer_border(struct wmOperatorType *ot);
|
||||
|
||||
extern const char *node_context_dir[];
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ void node_operatortypes(void)
|
||||
WM_operatortype_append(NODE_OT_shader_script_update);
|
||||
|
||||
WM_operatortype_append(NODE_OT_viewer_border);
|
||||
WM_operatortype_append(NODE_OT_clear_viewer_border);
|
||||
|
||||
WM_operatortype_append(NODE_OT_tree_socket_add);
|
||||
WM_operatortype_append(NODE_OT_tree_socket_remove);
|
||||
@@ -321,6 +322,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "NODE_OT_clipboard_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
|
||||
#endif
|
||||
WM_keymap_add_item(keymap, "NODE_OT_viewer_border", BKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_clear_viewer_border", BKEY, KM_PRESS, KM_ALT | KM_CTRL, 0);
|
||||
|
||||
transform_keymap_for_space(keyconf, keymap, SPACE_NODE);
|
||||
}
|
||||
|
||||
@@ -658,30 +658,6 @@ static void rna_NodeTree_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *p
|
||||
{
|
||||
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
|
||||
|
||||
/* when using border, make it so no old data from outside of
|
||||
* border is hanging around
|
||||
* ideally shouldn't be in RNA callback, but how to teach
|
||||
* compo to only clear frame when border usage is actually
|
||||
* toggling
|
||||
*/
|
||||
if (ntree->flag & NTREE_VIEWER_BORDER) {
|
||||
Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
void *lock;
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
|
||||
if (ibuf) {
|
||||
if (ibuf->rect)
|
||||
memset(ibuf->rect, 0, 4 * ibuf->x * ibuf->y);
|
||||
|
||||
if (ibuf->rect_float)
|
||||
memset(ibuf->rect_float, 0, 4 * ibuf->x * ibuf->y * sizeof(float));
|
||||
|
||||
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(ima, ibuf, lock);
|
||||
}
|
||||
|
||||
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
|
||||
WM_main_add_notifier(NC_SCENE | ND_NODES, &ntree->id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user