From 813800f143b90480f563d1e1dd6fbb9acd3e5f87 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Feb 2019 22:51:37 +1100 Subject: DRW: support clipping for stick & wire bones --- source/blender/draw/modes/shaders/armature_stick_vert.glsl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/draw/modes') diff --git a/source/blender/draw/modes/shaders/armature_stick_vert.glsl b/source/blender/draw/modes/shaders/armature_stick_vert.glsl index c27b8d34ec6..3f1aef47dce 100644 --- a/source/blender/draw/modes/shaders/armature_stick_vert.glsl +++ b/source/blender/draw/modes/shaders/armature_stick_vert.glsl @@ -1,6 +1,7 @@ uniform mat4 ProjectionMatrix; uniform mat4 ViewProjectionMatrix; +uniform mat4 ModelMatrix; uniform mat4 ViewMatrix; uniform vec2 viewportSize; @@ -49,8 +50,10 @@ void main() /* Make the color */ colorFac = ((flag & COL_WIRE) == 0u) ? ((flag & COL_BONE) != 0u) ? 1.0 : 2.0 : 0.0; - vec4 v0 = ViewMatrix * vec4(boneStart, 1.0); - vec4 v1 = ViewMatrix * vec4(boneEnd, 1.0); + vec4 boneStart_4d = vec4(boneStart, 1.0); + vec4 boneEnd_4d = vec4(boneEnd, 1.0); + vec4 v0 = ViewMatrix * boneStart_4d; + vec4 v1 = ViewMatrix * boneEnd_4d; /* Clip the bone to the camera origin plane (not the clip plane) * to avoid glitches if one end is behind the camera origin (in persp). */ @@ -81,6 +84,10 @@ void main() gl_Position = (is_head) ? p0 : p1; gl_Position.xy += stickSize * (vpos / viewportSize); gl_Position.z += (is_bone) ? 0.0 : 1e-6; /* Avoid Z fighting of head/tails. */ + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((ModelMatrix * (is_head ? boneStart_4d : boneEnd_4d)).xyz); +#endif } else { gl_Position = vec4(0.0); -- cgit v1.2.3