[Bf-blender-cvs] [689c042b2d4] greasepencil-refactor: GPencil: Implement Fade Layers
Antonio Vazquez
noreply at git.blender.org
Mon Jan 20 17:49:13 CET 2020
Commit: 689c042b2d41eec768ac6025f5a771d956b400ad
Author: Antonio Vazquez
Date: Mon Jan 20 17:48:49 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB689c042b2d41eec768ac6025f5a771d956b400ad
GPencil: Implement Fade Layers
===================================================================
M source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 9871da45130..55a8c3bce71 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -106,6 +106,10 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob)
GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd, Object *ob, bGPDlayer *gpl)
{
+ const bool is_fade = ((pd->fade_layer_opacity > -1.0f) && (pd->obact) && (pd->obact == ob) &&
+ ((gpl->flag & GP_LAYER_ACTIVE) == 0));
+ float fade_layer_opacity = (!is_fade) ? gpl->opacity : pd->fade_layer_opacity;
+
bGPdata *gpd = (bGPdata *)ob->data;
GPENCIL_tLayer *tgp_layer = BLI_memblock_alloc(pd->gp_layer_pool);
@@ -156,7 +160,7 @@ GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd, Object *ob, bGP
GPUShader *sh = GPENCIL_shader_layer_mask_get();
DRWShadingGroup *grp = DRW_shgroup_create(sh, tgp_layer->blend_ps);
DRW_shgroup_uniform_int_copy(grp, "isFirstPass", true);
- DRW_shgroup_uniform_float_copy(grp, "maskOpacity", gpl->opacity);
+ DRW_shgroup_uniform_float_copy(grp, "maskOpacity", fade_layer_opacity);
DRW_shgroup_uniform_bool_copy(grp, "maskInvert", gpl->flag & GP_LAYER_MASK_INVERT);
DRW_shgroup_uniform_texture_ref(grp, "colorBuf", &pd->color_masked_tx);
DRW_shgroup_uniform_texture_ref(grp, "revealBuf", &pd->reveal_masked_tx);
@@ -174,7 +178,7 @@ GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd, Object *ob, bGP
pd->use_mask_fb = true;
}
- else if ((gpl->blend_mode != eGplBlendMode_Regular) || (gpl->opacity < 1.0f)) {
+ else if ((gpl->blend_mode != eGplBlendMode_Regular) || (fade_layer_opacity < 1.0f)) {
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL;
switch (gpl->blend_mode) {
case eGplBlendMode_Regular:
@@ -203,7 +207,7 @@ GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd, Object *ob, bGP
GPUShader *sh = GPENCIL_shader_layer_blend_get();
DRWShadingGroup *grp = DRW_shgroup_create(sh, tgp_layer->blend_ps);
DRW_shgroup_uniform_int_copy(grp, "blendMode", gpl->blend_mode);
- DRW_shgroup_uniform_float_copy(grp, "blendOpacity", gpl->opacity);
+ DRW_shgroup_uniform_float_copy(grp, "blendOpacity", fade_layer_opacity);
DRW_shgroup_uniform_texture_ref(grp, "colorBuf", &pd->color_layer_tx);
DRW_shgroup_uniform_texture_ref(grp, "revealBuf", &pd->reveal_layer_tx);
DRW_shgroup_stencil_mask(grp, 0xFF);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index c91c0af002f..d1af5d461fe 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -187,11 +187,17 @@ void GPENCIL_cache_init(void *ved)
Scene *scene = draw_ctx->scene;
pd->simplify_fill = GPENCIL_SIMPLIFY_FILL(scene, playing);
pd->simplify_fx = GPENCIL_SIMPLIFY_FX(scene, playing);
+
+ /* Fade Layer. */
+ const bool is_fade = ((!hide_overlay) &&
+ (draw_ctx->v3d->gp_flag & V3D_GP_FADE_NOACTIVE_LAYERS));
+ pd->fade_layer_opacity = (is_fade) ? draw_ctx->v3d->overlay.gpencil_fade_layer : -1.0f;
}
else {
pd->do_onion = true;
pd->simplify_fill = false;
pd->simplify_fx = false;
+ pd->fade_layer_opacity = -1.0f;
}
{
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 558e3c3fbeb..9fd3061f4b9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -327,6 +327,8 @@ typedef struct GPENCIL_PrivateData {
/* Some blend mode needs to add negative values.
* This is only supported if target texture is signed. */
bool use_signed_fb;
+ /* Layer opacity for fading. */
+ float fade_layer_opacity;
} GPENCIL_PrivateData;
/* geometry batch cache functions */
More information about the Bf-blender-cvs
mailing list