diff options
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 421cb0ac4f1..ea3782c274a 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -2667,6 +2667,7 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, bGPDframe *act_gpf = gpl->actframe; bGPDframe *sta_gpf = act_gpf; bGPDframe *end_gpf = act_gpf ? act_gpf->next : NULL; + float prev_opacity = gpl->opacity; if (gpl->flag & GP_LAYER_HIDE) { continue; @@ -2682,9 +2683,12 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, * This is used only in final render and never in Viewport. */ if ((view_layer != NULL) && (gpl->viewlayername[0] != '\0') && (!STREQ(view_layer->name, gpl->viewlayername))) { - /* If the layer is used as mask, cannot be filtered or the masking system - * will crash because needs the mask layer in the draw pipeline. */ - if (!gpencil_is_layer_mask(view_layer, gpd, gpl)) { + /* Do not skip masks when rendering the viewlayer so that it can still be used to clip + * other layers. Instead set their opacity to zero. */ + if (gpencil_is_layer_mask(view_layer, gpd, gpl)) { + gpl->opacity = 0.0f; + } + else { continue; } } @@ -2779,6 +2783,7 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, if (layer_cb) { layer_cb(gpl, act_gpf, NULL, thunk); } + gpl->opacity = prev_opacity; continue; } @@ -2816,6 +2821,7 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, /* If layer solo mode and Paint mode, only keyframes with data are displayed. */ if (GPENCIL_PAINT_MODE(gpd) && (gpl->flag & GP_LAYER_SOLO_MODE) && (act_gpf->framenum != cfra)) { + gpl->opacity = prev_opacity; continue; } @@ -2826,6 +2832,9 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, stroke_cb(gpl, act_gpf, gps, thunk); } } + + /* Restore the opacity in case it was overwritten (used to hide masks in render). */ + gpl->opacity = prev_opacity; } } |