diff options
author | Simon Lenz <Amudtogal> | 2022-06-15 16:15:23 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-06-20 17:04:15 +0300 |
commit | eca0c95d51a8cede2475d1c77d5f6615623bda01 (patch) | |
tree | fe61b6035c7dc067987bb58e6684319aee54b94d /source/blender/editors | |
parent | 72a5bb8ba98a2866709cfa1645f31771280368db (diff) |
Mask Editor: Add mask blending factor for combined overlay
This adds a new parameter to the "Combined" overlay mode of the mask editor.
The "blending factor" allows users to blend the mask exterior with the original
footage to visualise the content of the mask in a more intuitive way. The
"Alpha" overlay is unaffected by this change.
The existing "Combined" overlay is used like before (covering everything
outside the mask in black), but can be blended with the slider in the mask
overlay to look at the exterior.
This is part of an effort to make mask editing more intuitive & easy to use:
https://developer.blender.org/T93097
Differential Revision: https://developer.blender.org/D13284
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_mask.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_draw.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 1 |
4 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 92df3d8d682..6d4d4fcff48 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -86,6 +86,7 @@ void ED_mask_draw_region(struct Depsgraph *depsgraph, char draw_flag, char draw_type, eMaskOverlayMode overlay_mode, + float blend_factor, int width_i, int height_i, float aspx, diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index aab4007854f..1bd224fe763 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -663,6 +663,7 @@ void ED_mask_draw_region( const char draw_flag, const char draw_type, const eMaskOverlayMode overlay_mode, + const float blend_factor, /* convert directly into aspect corrected vars */ const int width_i, const int height_i, @@ -721,12 +722,14 @@ void ED_mask_draw_region( } if (draw_flag & MASK_DRAWFLAG_OVERLAY) { - const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + float buf_col[4] = {1.0f, 0.0f, 0.0f, 0.0f}; float *buffer = mask_rasterize(mask_eval, width, height); if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { /* More blending types could be supported in the future. */ - GPU_blend(GPU_BLEND_MULTIPLY); + GPU_blend(GPU_BLEND_ALPHA); + buf_col[0] = -1.0f; + buf_col[3] = 1.0f; } GPU_matrix_push(); @@ -737,10 +740,18 @@ void ED_mask_draw_region( } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector( - state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); - immDrawPixelsTexTiled( - &state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, NULL); + state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, buf_col); + if (overlay_mode == MASK_OVERLAY_COMBINED) { + const float blend_col[4] = {0.0f, 0.0f, 0.0f, blend_factor}; + + immDrawPixelsTexTiled( + &state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, blend_col); + } + else { + immDrawPixelsTexTiled( + &state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, NULL); + } GPU_matrix_pop(); if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 5f52e1a3071..a73883e7624 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -860,6 +860,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *region) sc->mask_info.draw_flag, sc->mask_info.draw_type, sc->mask_info.overlay_mode, + sc->mask_info.blend_factor, mask_width, mask_height, aspx, diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index ab8143c5bf5..785a5419e04 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -694,6 +694,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region) sima->mask_info.draw_flag & ~MASK_DRAWFLAG_OVERLAY, sima->mask_info.draw_type, sima->mask_info.overlay_mode, + sima->mask_info.blend_factor, width, height, aspx, |