Commit: e6605d5f3746c1610b4f6e976c7e29074e82c3cd
Author: Alexander Gavrilov
Date:   Thu Nov 29 17:51:25 2018 +0300
Branches: blender2.8
https://developer.blender.org/rBe6605d5f3746c1610b4f6e976c7e29074e82c3cd

Fix depth offset in paint mode wireframe.

The original offset was wrong because it applied a constant to
homogenous coordinates (the actual depth is z/w), which broke
totally if near clip distance was reduced.

A correct depth offset has to take slope into account like
glPolygonOffset in order to avoid dotted lines caused by
interpolation precision variations. When drawing wire lines
however only the slope of the line itself is accessible, so
also generally increase the offset when the object is close.

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

M       source/blender/draw/modes/shaders/paint_wire_frag.glsl
M       source/blender/draw/modes/shaders/paint_wire_vert.glsl

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

diff --git a/source/blender/draw/modes/shaders/paint_wire_frag.glsl 
b/source/blender/draw/modes/shaders/paint_wire_frag.glsl
index b6637fea308..c5d6198fc21 100644
--- a/source/blender/draw/modes/shaders/paint_wire_frag.glsl
+++ b/source/blender/draw/modes/shaders/paint_wire_frag.glsl
@@ -11,6 +11,9 @@ void main()
                discard;
        }
 
+       /* Apply depth offset by taking slope and distance into account. */
+       gl_FragDepth = gl_FragCoord.z - mix(exp2(-10), exp2(-23), 
gl_FragCoord.z) - 2.0 * fwidth(gl_FragCoord.z);
+
 #ifdef VERTEX_MODE
        vec4 colSel = colorEdgeSelect;
        colSel.rgb = clamp(colSel.rgb - 0.2, 0.0, 1.0);
diff --git a/source/blender/draw/modes/shaders/paint_wire_vert.glsl 
b/source/blender/draw/modes/shaders/paint_wire_vert.glsl
index 6a800e56d94..253c21745e2 100644
--- a/source/blender/draw/modes/shaders/paint_wire_vert.glsl
+++ b/source/blender/draw/modes/shaders/paint_wire_vert.glsl
@@ -10,8 +10,5 @@ void main()
 {
        gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
 
-       /* Temp hack for william to start using blender 2.8 for icons. Will be 
removed by T54910 */
-       gl_Position.z -= 0.0001;
-
        finalFlag = data;
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to