[Bf-blender-cvs] [a3c998e4f30] greasepencil-refactor: GPencil: Refactor: Implement Layer Masking
Clément Foucault
noreply at git.blender.org
Sat Dec 14 03:31:25 CET 2019
Commit: a3c998e4f30ba9ed88c5f8c4cb46d44b98e31e64
Author: Clément Foucault
Date: Sat Dec 14 03:21:50 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBa3c998e4f30ba9ed88c5f8c4cb46d44b98e31e64
GPencil: Refactor: Implement Layer Masking
===================================================================
M source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index a22a4741f3c..293fd306721 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -74,6 +74,14 @@ GPENCIL_tLayer *gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
/* We render all strokes with uniform depth (increasing with stroke id). */
state |= DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_GREATER;
}
+
+ if (gpl->flag & GP_LAYER_USE_MASK) {
+ state |= DRW_STATE_STENCIL_EQUAL;
+ }
+ else {
+ state |= DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
+ }
+
tgp_layer->geom_ps = DRW_pass_create("GPencil Layer", state);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 47755bcc43a..f0bc2b91bea 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -830,6 +830,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
DRW_shgroup_uniform_float_copy(iter->grp, "thicknessWorldScale", thickness_scale);
DRW_shgroup_uniform_float_copy(iter->grp, "vertexColorOpacity", gpl->vertex_paint_opacity);
DRW_shgroup_uniform_vec4_copy(iter->grp, "layerTint", gpl->tintcolor);
+ DRW_shgroup_stencil_mask(iter->grp, 0xFF);
}
static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
@@ -1049,7 +1050,7 @@ static void GPENCIL_cache_finish_new(void *ved)
const float *size = DRW_viewport_size_get();
pd->depth_tx = DRW_texture_pool_query_2d(
- size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_gpencil_type);
+ size[0], size[1], GPU_DEPTH24_STENCIL8, &draw_engine_gpencil_type);
pd->color_tx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_R11F_G11F_B10F, &draw_engine_gpencil_type);
pd->reveal_tx = DRW_texture_pool_query_2d(
@@ -1303,7 +1304,7 @@ static void GPENCIL_draw_scene_new(void *ved)
DRW_stats_group_start("GPencil Object");
GPU_framebuffer_bind(fbl->gpencil_fb);
- GPU_framebuffer_clear_depth(fbl->gpencil_fb, ob->is_drawmode3d ? 1.0f : 0.0f);
+ GPU_framebuffer_clear_depth_stencil(fbl->gpencil_fb, ob->is_drawmode3d ? 1.0f : 0.0f, 0x00);
if (ob->vfx.first) {
/* TODO vfx */
More information about the Bf-blender-cvs
mailing list