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:
authorClément Foucault <foucault.clem@gmail.com>2018-08-20 16:47:11 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-08-20 16:47:22 +0300
commit47d43c5a00aed963cc59eee35e263e4d3eb9f66d (patch)
treee10969e3916f492d1b9f71e660915d29e8901a99 /source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
parent939a5cb6eecc45d925a147b8b6f6a1225679bc45 (diff)
Bone Display: fix flickering issue with BBones in ortho view
Diffstat (limited to 'source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl')
-rw-r--r--source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl18
1 files changed, 14 insertions, 4 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 4d6f3e94693..91468bf920a 100644
--- a/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
+++ b/source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
@@ -23,17 +23,18 @@ vec2 compute_dir(vec2 v0, vec2 v1)
void emit_edge(vec2 edge_dir, vec2 hidden_dir, vec2 thick, bool is_persp)
{
float fac = dot(-hidden_dir, edge_dir);
+ edge_dir *= (fac < 0.0) ? -1.0 : 1.0;
vec2 t = thick * (is_persp ? abs(vPos[1].z) : 1.0);
gl_Position = pPos[1];
EmitVertex();
- gl_Position.xy += t * edge_dir * sign(fac);
+ gl_Position.xy += t * edge_dir;
EmitVertex();
t = thick * (is_persp ? abs(vPos[2].z) : 1.0);
gl_Position = pPos[2];
EmitVertex();
- gl_Position.xy += t * edge_dir * sign(fac);
+ gl_Position.xy += t * edge_dir;
EmitVertex();
}
@@ -75,9 +76,18 @@ void main(void)
vec2 thick = vColSize[0].w * (lineThickness / viewportSize);
vec2 edge_dir = compute_dir(ssPos[1], ssPos[2]);
+ vec2 hidden_point;
/* Take the farthest point to compute edge direction
- * (avoid problems with point behind near plane). */
- vec2 hidden_point = (vPos[0].z < vPos[3].z) ? ssPos[0] : ssPos[3];
+ * (avoid problems with point behind near plane).
+ * If the chosen point is parallel to the edge in screen space,
+ * choose the other point anyway.
+ * This fixes some issue with cubes in orthographic views.*/
+ if (vPos[0].z < vPos[3].z) {
+ hidden_point = (abs(fac0) > 1e-5) ? ssPos[0] : ssPos[3];
+ }
+ else {
+ hidden_point = (abs(fac3) > 1e-5) ? ssPos[3] : ssPos[0];
+ }
vec2 hidden_dir = normalize(hidden_point - ssPos[1]);
emit_corner(1, thick, is_persp);