[Bf-blender-cvs] [4b8d091c904] greasepencil-object: Reorganize Mask button and rename to Clamp
Antonioya
noreply at git.blender.org
Mon Nov 26 17:34:51 CET 2018
Commit: 4b8d091c904b5004ed70171bc0408be40fa7acf0
Author: Antonioya
Date: Mon Nov 26 17:34:40 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB4b8d091c904b5004ed70171bc0408be40fa7acf0
Reorganize Mask button and rename to Clamp
Now the Clamp is valid in Normal layers and the value is OFF by default.
===================================================================
M release/scripts/startup/bl_ui/properties_data_gpencil.py
M release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M release/scripts/startup/bl_ui/space_topbar.py
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
M source/blender/makesrna/intern/rna_gpencil.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 52049704ded..558c3c190b6 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -139,12 +139,11 @@ class DATA_PT_gpencil_datapanel(Panel):
if gpl:
srow = col.row(align=True)
srow.prop(gpl, "blend_mode", text="Blend")
- subrow = srow.row(align=True)
- subrow.enabled = gpl.blend_mode != 'NORMAL'
- subrow.prop(gpl, "disable_mask", text="", icon='MOD_MASK')
srow = col.row(align=True)
srow.prop(gpl, "opacity", text="Opacity", slider=True)
+ srow.prop(gpl, "clamp_layer", text="",
+ icon='MOD_MASK' if gpl.clamp_layer else 'ONIONSKIN_OFF')
col = row.column()
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 14f59d0b369..b18254a9102 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -872,6 +872,10 @@ class GPENCIL_UL_layer(UIList):
row.prop(gpl, "info", text="", emboss=False)
row = layout.row(align=True)
+ row.prop(gpl, "clamp_layer", text="",
+ icon='MOD_MASK' if gpl.clamp_layer else 'ONIONSKIN_OFF',
+ emboss=False)
+
row.prop(gpl, "lock", text="", emboss=False)
row.prop(gpl, "hide", text="", emboss=False)
subrow = row.row(align=True)
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index db6e7e62ea4..a769268bb22 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -520,12 +520,11 @@ class TOPBAR_PT_gpencil_layers(Panel):
if gpl:
srow = col.row(align=True)
srow.prop(gpl, "blend_mode", text="Blend")
- subrow = srow.row(align=True)
- subrow.enabled = gpl.blend_mode != 'NORMAL'
- subrow.prop(gpl, "disable_mask", text="", icon='MOD_MASK')
srow = col.row(align=True)
srow.prop(gpl, "opacity", text="Opacity", slider=True)
+ srow.prop(gpl, "clamp_layer", text="",
+ icon='MOD_MASK' if gpl.clamp_layer else 'ONIONSKIN_OFF')
col = row.column()
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 7ec0517cb28..e4d6fa582b8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1409,7 +1409,7 @@ static void DRW_gpencil_shgroups_create(
if ((shgrp != NULL) && (tag_first)) {
array_elm = &cache_ob->shgrp_array[idx];
array_elm->mode = idx == 0 ? eGplBlendMode_Normal: gpl->blend_mode;
- array_elm->disable_mask = gpl->flag & GP_LAYER_USE_MASK;
+ array_elm->clamp_layer = gpl->flag & GP_LAYER_USE_MASK;
array_elm->blend_opacity = gpl->opacity;
array_elm->init_shgrp = shgrp;
cache_ob->tot_layers++;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 6673e4a0564..a80ad133d09 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -504,7 +504,7 @@ void GPENCIL_cache_init(void *vedata)
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendColor", &e_data.temp_color_tx_fx);
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendDepth", &e_data.temp_depth_tx_fx);
DRW_shgroup_uniform_int(blend_shgrp, "mode", &stl->storage->blend_mode, 1);
- DRW_shgroup_uniform_int(blend_shgrp, "disable_mask", &stl->storage->disable_mask, 1);
+ DRW_shgroup_uniform_int(blend_shgrp, "clamp_layer", &stl->storage->clamp_layer, 1);
DRW_shgroup_uniform_float(blend_shgrp, "blend_opacity", &stl->storage->blend_opacity, 1);
/* create effects passes */
@@ -675,21 +675,21 @@ static void gpencil_draw_pass_range(
GPENCIL_FramebufferList *fbl, GPENCIL_StorageList *stl,
GPENCIL_PassList *psl, GPENCIL_TextureList *txl,
GPUFrameBuffer *fb,
- DRWShadingGroup *init_shgrp, DRWShadingGroup *end_shgrp, int mode)
+ DRWShadingGroup *init_shgrp, DRWShadingGroup *end_shgrp, bool multi)
{
if (init_shgrp == NULL) {
return;
}
/* previews don't use AA */
- if ((!stl->storage->is_mat_preview) && (mode == eGplBlendMode_Normal)) {
+ if ((!stl->storage->is_mat_preview) && (multi)) {
MULTISAMPLE_GP_SYNC_ENABLE(stl->storage->multisamples, fbl);
}
DRW_draw_pass_subset(
psl->stroke_pass, init_shgrp, end_shgrp);
- if ((!stl->storage->is_mat_preview) && (mode == eGplBlendMode_Normal)) {
+ if ((!stl->storage->is_mat_preview) && (multi)) {
MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, fb, txl);
}
@@ -777,9 +777,13 @@ void GPENCIL_draw_scene(void *ved)
bool use_blend = false;
if (cache_ob->tot_layers > 0) {
for (int e = 0; e < cache_ob->tot_layers; e++) {
+ bool is_last = e == cache_ob->tot_layers - 1 ? true : false;
array_elm = &cache_ob->shgrp_array[e];
- if ((array_elm->mode == eGplBlendMode_Normal) && (!use_blend)) {
+ if (((array_elm->mode == eGplBlendMode_Normal) &&
+ (!use_blend) && (!array_elm->clamp_layer)) ||
+ ( e == 0))
+ {
if (init_shgrp == NULL) {
init_shgrp = array_elm->init_shgrp;
}
@@ -790,7 +794,7 @@ void GPENCIL_draw_scene(void *ved)
/* draw pending groups */
gpencil_draw_pass_range(
fbl, stl, psl, txl, fbl->temp_fb_a,
- init_shgrp, end_shgrp, array_elm->mode);
+ init_shgrp, end_shgrp, is_last);
/* draw current group in separated texture */
init_shgrp = array_elm->init_shgrp;
@@ -800,13 +804,14 @@ void GPENCIL_draw_scene(void *ved)
GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
gpencil_draw_pass_range(
fbl, stl, psl, txl, fbl->temp_fb_fx,
- init_shgrp, end_shgrp, array_elm->mode);
+ init_shgrp, end_shgrp,
+ is_last);
/* Blend A texture and FX texture */
GPU_framebuffer_bind(fbl->temp_fb_b);
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
stl->storage->blend_mode = array_elm->mode;
- stl->storage->disable_mask = (int)array_elm->disable_mask;
+ stl->storage->clamp_layer = (int)array_elm->clamp_layer;
stl->storage->blend_opacity = array_elm->blend_opacity;
DRW_draw_pass(psl->blend_pass);
@@ -824,7 +829,10 @@ void GPENCIL_draw_scene(void *ved)
}
/* last group */
- gpencil_draw_pass_range(fbl, stl, psl, txl, fbl->temp_fb_a, init_shgrp, end_shgrp, array_elm->mode);
+ gpencil_draw_pass_range(
+ fbl, stl, psl, txl, fbl->temp_fb_a,
+ init_shgrp, end_shgrp,
+ true);
}
/* Current buffer drawing */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index dc3870c1aae..b8b526cb873 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -61,7 +61,7 @@ struct RenderLayer;
/* *********** OBJECTS CACHE *********** */
typedef struct tGPencilObjectCache_shgrp {
int mode;
- bool disable_mask;
+ bool clamp_layer;
float blend_opacity;
DRWShadingGroup *init_shgrp;
DRWShadingGroup *end_shgrp;
@@ -139,7 +139,7 @@ typedef struct GPENCIL_Storage {
short multisamples;
int blend_mode;
- int disable_mask;
+ int clamp_layer;
float blend_opacity;
/* simplify settings*/
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
index b15b0b29a43..2ba02beecdb 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
@@ -7,7 +7,7 @@ uniform sampler2D strokeDepth;
uniform sampler2D blendColor;
uniform sampler2D blendDepth;
uniform int mode;
-uniform int disable_mask;
+uniform int clamp_layer;
uniform float blend_opacity;
#define ON 1
@@ -106,14 +106,19 @@ void main()
}
}
else {
- FragColor = mix_color;
- gl_FragDepth = mix_depth;
+ if (clamp_layer == ON) {
+ discard;
+ }
+ else {
+ FragColor = mix_color;
+ gl_FragDepth = mix_depth;
+ }
}
return;
}
/* if not using mask, return mix color */
- if ((stroke_color.a == 0) && (disable_mask == OFF)) {
+ if ((stroke_color.a == 0) && (clamp_layer == OFF)) {
FragColor = mix_color;
gl_FragDepth = mix_depth;
return;
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 138f5dadd8d..d6257aa0c1b 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1200,13 +1200,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Lock Material", "Disable Material editing");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
- prop = RNA_def_property(srna, "disable_mask", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_USE_MASK);
+ prop = RNA_def_property(srna, "clamp_layer", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_USE_MASK);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Disable Mask", "Disable underlying layers as mask");
+ RNA_def_property_ui_text(prop, "Clamp Layer",
+ "Clamp any pixel outside underlying layers drawing");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
/* exposed as layers.active */
#if 0
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
More information about the Bf-blender-cvs
mailing list