Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-06 23:44:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-07 00:03:56 +0300
commit7325035e60913ed8ef4afc61d22395e2382672dd (patch)
treee49020b11db8b50cbd316ec0cdd0067bd750c04f /source/blender/draw/modes
parent6152f5cd67d609afaea128ff07b201fb180137b5 (diff)
DRW: support clipping for octahedral & box bones
Diffstat (limited to 'source/blender/draw/modes')
-rw-r--r--source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl15
-rw-r--r--source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl7
-rw-r--r--source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl8
3 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl b/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
index e12c48453a7..0fdd874f1fd 100644
--- a/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
+++ b/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
@@ -27,14 +27,26 @@ void emit_edge(vec2 edge_dir, vec2 hidden_dir, vec2 thick, bool is_persp)
vec2 t = thick * (is_persp ? abs(vPos[1].z) : 1.0);
gl_Position = pPos[1];
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance);
+#endif
EmitVertex();
gl_Position.xy += t * edge_dir;
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance);
+#endif
EmitVertex();
t = thick * (is_persp ? abs(vPos[2].z) : 1.0);
gl_Position = pPos[2];
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[2].gl_ClipDistance);
+#endif
EmitVertex();
gl_Position.xy += t * edge_dir;
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[2].gl_ClipDistance);
+#endif
EmitVertex();
}
@@ -44,6 +56,9 @@ void emit_corner(const int e, vec2 thick, bool is_persp)
vec2 t = thick * (is_persp ? abs(vPos[e].z) : 1.0);
gl_Position = pPos[e] + vec4(t * corner_dir, 0.0, 0.0);
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[e].gl_ClipDistance);
+#endif
EmitVertex();
}
diff --git a/source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl b/source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl
index 27b75852a16..b190d834a61 100644
--- a/source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl
+++ b/source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl
@@ -31,7 +31,8 @@ void main()
* doing it per instance on CPU and sending it on via instance attribute. */
mat3 NormalMatrix = transpose(inverse(mat3(ViewMatrix * InstanceModelMatrix)));
- vec4 viewpos = ViewMatrix * (InstanceModelMatrix * vec4(pos, 1.0));
+ vec4 worldPosition = InstanceModelMatrix * vec4(pos, 1.0);
+ vec4 viewpos = ViewMatrix * worldPosition;
vPos = viewpos.xyz;
pPos = ProjectionMatrix * viewpos;
@@ -44,4 +45,8 @@ void main()
ssPos = proj(pPos);
vColSize = outlineColorSize;
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance(worldPosition.xyz);
+#endif
}
diff --git a/source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl b/source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl
index 4dfd542710b..8463ffab447 100644
--- a/source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl
+++ b/source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl
@@ -32,5 +32,11 @@ void main()
finalColor.rgb = mix(stateColor, boneColor, fac);
finalColor.a = 1.0;
- gl_Position = ViewProjectionMatrix * (InstanceModelMatrix * vec4(pos, 1.0));
+
+ vec4 worldPosition = InstanceModelMatrix * vec4(pos, 1.0);
+ gl_Position = ViewProjectionMatrix * worldPosition;
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance(worldPosition.xyz);
+#endif
}