[Bf-blender-cvs] [e08919bda2d] temp-angavrilov-constraints: Bone Overlay: support bone wireframe opacity settings.

Alexander Gavrilov noreply at git.blender.org
Wed Jan 13 15:36:14 CET 2021


Commit: e08919bda2d3bf900f15d0080924e41a09ad86aa
Author: Alexander Gavrilov
Date:   Sun Jan 3 23:40:44 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rBe08919bda2d3bf900f15d0080924e41a09ad86aa

Bone Overlay: support bone wireframe opacity settings.

When weight painting the bone overlay is extremely intrusive,
effectively requiring either extensive use of hiding individual
bones, or disabling the whole bone overlay between selections.

This addresses the issue by adding two bone opacity sliders that
are used for the 'wireframe' armature drawing mode. One directly
controls the opacity in a uniform way. The other one allows fade
based on the depth between the near and far clip planes in order
to provide an automatic visual cue about which bones are closest.

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/draw/CMakeLists.txt
M	source/blender/draw/engines/overlay/overlay_armature.c
M	source/blender/draw/engines/overlay/overlay_private.h
M	source/blender/draw/engines/overlay/overlay_shader.c
A	source/blender/draw/engines/overlay/shaders/armature_alpha_lib.glsl
M	source/blender/draw/engines/overlay/shaders/armature_dof_solid_frag.glsl
M	source/blender/draw/engines/overlay/shaders/armature_envelope_solid_frag.glsl
M	source/blender/draw/engines/overlay/shaders/armature_shape_solid_frag.glsl
M	source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl
M	source/blender/draw/engines/overlay/shaders/armature_stick_frag.glsl
M	source/blender/draw/engines/overlay/shaders/armature_wire_frag.glsl
M	source/blender/makesdna/DNA_view3d_defaults.h
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 55cb110177f..4748ec6a1ee 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6473,17 +6473,18 @@ class VIEW3D_PT_overlay_sculpt(Panel):
         row.prop(overlay, "sculpt_mode_face_sets_opacity", text="Face Sets")
 
 
-class VIEW3D_PT_overlay_pose(Panel):
+class VIEW3D_PT_overlay_bones(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'HEADER'
     bl_parent_id = 'VIEW3D_PT_overlay'
-    bl_label = "Pose Mode"
+    bl_label = "Bones"
 
     @classmethod
     def poll(cls, context):
         mode = context.mode
         return (
             (mode == 'POSE') or
+            (mode == 'EDIT_ARMATURE') or
             (mode == 'PAINT_WEIGHT' and context.pose_object)
         )
 
@@ -6503,10 +6504,14 @@ class VIEW3D_PT_overlay_pose(Panel):
             sub = row.row()
             sub.active = display_all and overlay.show_xray_bone
             sub.prop(overlay, "xray_alpha_bone", text="Fade Geometry")
-        else:
+        elif mode == 'PAINT_WEIGHT':
             row = col.row()
             row.prop(overlay, "show_xray_bone")
 
+        row = col.row()
+        row.prop(overlay, "bone_wire_alpha")
+        row.prop(overlay, "bone_wire_fade")
+
 
 class VIEW3D_PT_overlay_texture_paint(Panel):
     bl_space_type = 'VIEW_3D'
@@ -7675,7 +7680,7 @@ classes = (
     VIEW3D_PT_overlay_texture_paint,
     VIEW3D_PT_overlay_vertex_paint,
     VIEW3D_PT_overlay_weight_paint,
-    VIEW3D_PT_overlay_pose,
+    VIEW3D_PT_overlay_bones,
     VIEW3D_PT_overlay_sculpt,
     VIEW3D_PT_snapping,
     VIEW3D_PT_proportional_edit,
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 0581ff9e47c..cfe32d724b8 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1574,5 +1574,18 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_wire_alpha")) {
+      for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+        LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+          LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+            if (sl->spacetype == SPACE_VIEW3D) {
+              View3D *v3d = (View3D *)sl;
+              v3d->overlay.bone_wire_alpha = 1.0f;
+            }
+          }
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 9b716eeeed3..382f0dae001 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -331,6 +331,7 @@ data_to_c_simple(engines/basic/shaders/depth_frag.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/common_overlay_lib.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/antialiasing_frag.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/antialiasing_vert.glsl SRC)
+data_to_c_simple(engines/overlay/shaders/armature_alpha_lib.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/armature_dof_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/armature_dof_solid_frag.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/armature_envelope_outline_vert.glsl SRC)
diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c
index 5ae6eb48025..98e1455baf2 100644
--- a/source/blender/draw/engines/overlay/overlay_armature.c
+++ b/source/blender/draw/engines/overlay/overlay_armature.c
@@ -139,6 +139,11 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
                                    draw_ctx->object_pose != NULL;
   DRWState state;
 
+  const float wire_alpha = pd->overlay.bone_wire_alpha;
+  const float wire_fade_fac = pd->overlay.bone_wire_fade;
+  const float wire_fade = wire_fade_fac ? expf((wire_fade_fac - 0.5f) * 8) : 0;
+  const bool use_wire_alpha = (wire_alpha < 1.0f || wire_fade > 0.0f);
+
   if (pd->armature.do_pose_fade_geom) {
     state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA;
     DRW_PASS_CREATE(psl->armature_bone_select_ps, state | pd->clipping_state);
@@ -162,8 +167,8 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
     OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get();
     OVERLAY_ArmatureCallBuffers *cb = &pd->armature_call_buffers[i];
 
-    cb->custom_shapes_ghash = BLI_ghash_ptr_new(__func__);
-    cb->custom_shapes_transp_ghash = BLI_ghash_ptr_new(__func__);
+    cb->solid.custom_shapes_ghash = BLI_ghash_ptr_new(__func__);
+    cb->transp.custom_shapes_ghash = BLI_ghash_ptr_new(__func__);
 
     DRWPass **p_armature_ps = &psl->armature_ps[i];
     DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0;
@@ -186,45 +191,86 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
       sh = OVERLAY_shader_armature_sphere(false);
       grp = DRW_shgroup_create(sh, armature_ps);
       DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
-      DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f);
-      cb->point_solid = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get());
+      DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){1.0f, 0.0f});
+      cb->solid.point_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get());
 
       grp = DRW_shgroup_create(sh, armature_ps);
       DRW_shgroup_state_disable(grp, DRW_STATE_WRITE_DEPTH);
       DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA);
-      DRW_shgroup_uniform_float_copy(grp, "alpha", 0.4f);
-      cb->point_transp = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get());
+      DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+      DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){wire_alpha * 0.4f, wire_fade});
+      cb->transp.point_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_point_get());
 
       sh = OVERLAY_shader_armature_shape(false);
       grp = DRW_shgroup_create(sh, armature_ps);
       DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
-      DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f);
-      cb->custom_solid = grp;
-      cb->box_solid = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get());
-      cb->octa_solid = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get());
+      DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){1.0f, 0.0f});
+      cb->solid.custom_fill = grp;
+      cb->solid.box_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get());
+      cb->solid.octa_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get());
 
       grp = DRW_shgroup_create(sh, armature_ps);
       DRW_shgroup_state_disable(grp, DRW_STATE_WRITE_DEPTH);
       DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA);
-      DRW_shgroup_uniform_float_copy(grp, "alpha", 0.6f);
-      cb->custom_transp = grp;
-      cb->box_transp = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get());
-      cb->octa_transp = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get());
+      DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+      DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){wire_alpha * 0.6f, wire_fade});
+      cb->transp.custom_fill = grp;
+      cb->transp.box_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_box_get());
+      cb->transp.octa_fill = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_get());
 
       sh = OVERLAY_shader_armature_sphere(true);
       grp = DRW_shgroup_create(sh, armature_ps);
       DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
-      cb->point_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_point_wire_outline_get());
+      DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){1.0f, 0.0f});
+      cb->solid.point_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_point_wire_outline_get());
+
+      if (use_wire_alpha) {
+        grp = DRW_shgroup_create(sh, armature_ps);
+        DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA);
+        DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+        DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){wire_alpha, wire_fade});
+        cb->transp.point_outline = BUF_INSTANCE(
+            grp, format, DRW_cache_bone_point_wire_outline_get());
+      }
+      else {
+        cb->transp.point_outline = cb->solid.point_outline;
+      }
 
       sh = OVERLAY_shader_armature_shape(true);
-      cb->custom_outline = grp = DRW_shgroup_create(sh, armature_ps);
+      cb->solid.custom_outline = grp = DRW_shgroup_create(sh, armature_ps);
       DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
-      cb->box_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_box_wire_get());
-      cb->octa_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_wire_get());
+      DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){1.0f, 0.0f});
+      cb->solid.box_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_box_wire_get());
+      cb->solid.octa_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_wire_get());
+
+      if (use_wire_alpha) {
+        cb->transp.custom_outline = grp = DRW_shgroup_create(sh, armature_ps);
+        DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA);
+        DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+        DRW_shgroup_uniform_vec2_copy(grp, "wireAlpha", (float[2]){wire_alpha, wire_fade});
+        cb->transp.box_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_box_wire_get());
+        cb->transp.octa_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_wire_get());
+      }
+      else {
+        cb->transp.custom_outline = cb->solid.custom_outline;
+        cb->transp.box_outline = cb->solid.box_outline;
+        cb->transp.octa_outline = cb->solid.octa_outline;
+      }
 
       sh = OVERLAY_shader_armature_shape_wire();
-      cb->custom_wire = grp = DRW_shgroup_create(sh, armature_ps);
+      cb->solid.custom_wire = grp = DRW_shgr

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list