Commit: f2792e91f034ed01469aa025503a4352a1e4455c
Author: Pablo Dobarro
Date:   Sat Apr 20 11:58:44 2019 +0200
Branches: master
https://developer.blender.org/rBf2792e91f034ed01469aa025503a4352a1e4455c

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

===================================================================

M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/draw/modes/sculpt_mode.c
M       source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
M       source/blender/editors/space_view3d/space_view3d.c
M       source/blender/makesdna/DNA_view3d_types.h
M       source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index f572362b02b..bb56946e154 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -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):
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index e43553cd64f..5f13bea1c28 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -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. */
   }
 }
diff --git a/source/blender/draw/modes/sculpt_mode.c 
b/source/blender/draw/modes/sculpt_mode.c
index b25a8af795b..e2b73a0fac7 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -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;
   }
 }
 
diff --git a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl 
b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
index 5ae97ec5cb9..e5e34fee57e 100644
--- a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
+++ b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
@@ -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);
 }
diff --git a/source/blender/editors/space_view3d/space_view3d.c 
b/source/blender/editors/space_view3d/space_view3d.c
index 0b98ad3cacd..456a012020f 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -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 |
diff --git a/source/blender/makesdna/DNA_view3d_types.h 
b/source/blender/makesdna/DNA_view3d_types.h
index 74277e60c37..60a7752fee2 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -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;
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index af1f37701ee..f2a79fba503 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -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);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to