[Bf-blender-cvs] [a3a6cda8fb6] master: Fix T65745: Bone Selection X-Ray Drawing.

Jeroen Bakker noreply at git.blender.org
Fri Jun 21 09:47:24 CEST 2019


Commit: a3a6cda8fb678432e0552d23b0226e8617f26e5f
Author: Jeroen Bakker
Date:   Thu Jun 20 16:50:08 2019 +0200
Branches: master
https://developer.blender.org/rBa3a6cda8fb678432e0552d23b0226e8617f26e5f

Fix T65745: Bone Selection X-Ray Drawing.

The Pose Bone Selection used normal matric multiplication, but that
mismatched the Depth buffer from all draw engines. They used the
optimized matrices from common_view_lib.

This change will use the optimized version, so the depth buffer matches
and the render artifacts would be correct.

Please note that bone selection is not using shcfg and therefore render clipping is still off.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5100

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

M	source/blender/draw/CMakeLists.txt
M	source/blender/draw/modes/pose_mode.c
A	source/blender/draw/modes/shaders/pose_selection_vert.glsl

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

diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 44551a4e04b..5a8a4d46ac9 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -325,6 +325,7 @@ data_to_c_simple(modes/shaders/paint_wire_vert.glsl SRC)
 data_to_c_simple(modes/shaders/paint_vert_frag.glsl SRC)
 data_to_c_simple(modes/shaders/particle_strand_frag.glsl SRC)
 data_to_c_simple(modes/shaders/particle_strand_vert.glsl SRC)
+data_to_c_simple(modes/shaders/pose_selection_vert.glsl SRC)
 data_to_c_simple(modes/shaders/sculpt_mask_vert.glsl SRC)
 data_to_c_simple(modes/shaders/volume_velocity_vert.glsl SRC)
 
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 8cdf28f177a..3a5c87688fe 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -35,6 +35,10 @@
 #include "draw_common.h"
 #include "draw_mode_engines.h"
 
+extern char datatoc_common_view_lib_glsl[];
+extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
+extern char datatoc_pose_selection_vert_glsl[];
+
 /* *********** LISTS *********** */
 /**
  * All lists are per viewport specific datas.
@@ -93,12 +97,18 @@ static bool POSE_is_bone_selection_overlay_active(void)
 static void POSE_engine_init(void *UNUSED(vedata))
 {
   if (!e_data.bone_selection_sh) {
-    e_data.bone_selection_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
+    e_data.bone_selection_sh = DRW_shader_create_with_lib(
+        datatoc_pose_selection_vert_glsl,
+        NULL,
+        datatoc_gpu_shader_uniform_color_frag_glsl,
+        datatoc_common_view_lib_glsl,
+        NULL);
   }
 }
 
 static void POSE_engine_free(void)
 {
+  DRW_SHADER_FREE_SAFE(e_data.bone_selection_sh);
 }
 
 /* Here init all passes and shading groups
diff --git a/source/blender/draw/modes/shaders/pose_selection_vert.glsl b/source/blender/draw/modes/shaders/pose_selection_vert.glsl
new file mode 100644
index 00000000000..2dd84c0a060
--- /dev/null
+++ b/source/blender/draw/modes/shaders/pose_selection_vert.glsl
@@ -0,0 +1,12 @@
+
+in vec3 pos;
+
+void main()
+{
+  vec3 world_pos = point_object_to_world(pos);
+  gl_Position = point_world_to_ndc(world_pos);
+
+#ifdef USE_WORLD_CLIP_PLANES
+  world_clip_planes_calc_clip_distance(world_pos);
+#endif
+}



More information about the Bf-blender-cvs mailing list