3D View: add opacity for sculpt mask display

This matches vertex/texture paint opacity options.

Useful because 0.75 is sometimes too dark to see the surface shading.

Resolves T63746
This commit is contained in:
2019-04-20 11:58:44 +02:00
committed by Campbell Barton
parent 08f4cdebe4
commit f2792e91f0
7 changed files with 41 additions and 3 deletions

View File

@@ -5572,8 +5572,14 @@ class VIEW3D_PT_overlay_sculpt(Panel):
tool_settings = context.tool_settings
sculpt = tool_settings.sculpt
view = context.space_data
overlay = view.overlay
layout.prop(sculpt, "show_diffuse_color")
layout.prop(sculpt, "show_mask")
row = layout.row()
row.active = sculpt.show_mask
row.prop(overlay, "sculpt_mode_mask_opacity", text="Opacity")
class VIEW3D_PT_overlay_pose(Panel):

View File

@@ -3177,6 +3177,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
if (!DNA_struct_elem_find(
fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
}
}
}
}
}
/* Versioning code until next subversion bump goes here. */
}
}

View File

@@ -135,9 +135,15 @@ static void SCULPT_cache_init(void *vedata)
}
{
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY;
psl->pass = DRW_pass_create("Sculpt Pass", state);
stl->g_data->group_smooth = DRW_shgroup_create(e_data.shader_smooth, psl->pass);
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_smooth, psl->pass);
DRW_shgroup_uniform_float(shgrp, "maskOpacity", &v3d->overlay.sculpt_mode_mask_opacity, 1);
stl->g_data->group_smooth = shgrp;
}
}

View File

@@ -1,5 +1,6 @@
uniform mat4 ModelViewProjectionMatrix;
uniform float maskOpacity;
in vec3 pos;
in float msk;
@@ -10,6 +11,6 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
float mask = 1.0 - msk * 0.75;
float mask = 1.0 - (msk * maskOpacity);
finalColor = vec4(mask, mask, mask, 1.0);
}

View File

@@ -262,6 +262,10 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->overlay.texture_paint_mode_opacity = 1.0f;
v3d->overlay.weight_paint_mode_opacity = 1.0f;
v3d->overlay.vertex_paint_mode_opacity = 1.0f;
/* Intentionally different to vertex/paint mode,
* we typically want to see shading too. */
v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
v3d->overlay.edit_flag = V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS |
V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE |
V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES |

View File

@@ -200,12 +200,12 @@ typedef struct View3DOverlay {
/** Weight paint mode settings. */
int wpaint_flag;
char _pad2[4];
/** Alpha for texture, weight, vertex paint overlay. */
float texture_paint_mode_opacity;
float vertex_paint_mode_opacity;
float weight_paint_mode_opacity;
float sculpt_mode_mask_opacity;
/** Armature edit/pose mode settings. */
int _pad3;

View File

@@ -3468,6 +3468,13 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "sculpt_mode_mask_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_mask_opacity");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Sculpt Mask Opacity", "");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
/* grease pencil paper settings */
prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_ANNOTATION);