[Bf-blender-cvs] [47d43c5a00a] blender2.8: Bone Display: fix flickering issue with BBones in ortho view

Clément Foucault noreply at git.blender.org
Mon Aug 20 15:47:28 CEST 2018


Commit: 47d43c5a00aed963cc59eee35e263e4d3eb9f66d
Author: Clément Foucault
Date:   Mon Aug 20 15:47:11 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB47d43c5a00aed963cc59eee35e263e4d3eb9f66d

Bone Display: fix flickering issue with BBones in ortho view

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

M	source/blender/draw/modes/shaders/armature_shape_outline_geom.glsl
M	source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl

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

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);
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 3e7a185bb62..117bd6f6bbb 100644
--- a/source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl
+++ b/source/blender/draw/modes/shaders/armature_shape_outline_vert.glsl
@@ -7,7 +7,6 @@ uniform vec2 viewportSize;
 
 /* ---- Instanciated Attribs ---- */
 in vec3 pos;
-in vec3 nor;
 in vec3 snor;
 
 /* ---- Per instance Attribs ---- */



More information about the Bf-blender-cvs mailing list