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-06-10 20:35:25 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-06-10 21:06:26 +0300
commit542462d35c5c17742aa4d3d17c13bbbf312fe7a3 (patch)
tree0cfe5284da09612beaacc42765cb192586de1650 /source/blender/draw/modes/shaders
parente321fc4a7c8f93d5ffee50d107430df04b612e23 (diff)
Workbench: Xray: Add selected/active non-occluded outlines
This Fix the problem when multiple objects are selected and one of them occlude the others. You cannot see clearly what is selected. With this option, selection is more clear when Xray mode is enabled.
Diffstat (limited to 'source/blender/draw/modes/shaders')
-rw-r--r--source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl40
-rw-r--r--source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl16
2 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl b/source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl
new file mode 100644
index 00000000000..c90195e11fd
--- /dev/null
+++ b/source/blender/draw/modes/shaders/object_outline_prepass_geom.glsl
@@ -0,0 +1,40 @@
+
+layout(lines_adjacency) in;
+layout(line_strip, max_vertices = 2) out;
+
+uniform mat4 ProjectionMatrix;
+
+in vec4 pPos[];
+in vec3 vPos[];
+
+void main()
+{
+ bool is_persp = (ProjectionMatrix[3][3] == 0.0);
+
+ vec3 view_vec = (is_persp) ? normalize(vPos[1]) : vec3(0.0, 0.0, -1.0);
+
+ vec3 v10 = vPos[0] - vPos[1];
+ vec3 v12 = vPos[2] - vPos[1];
+ vec3 v13 = vPos[3] - vPos[1];
+
+ vec3 n0 = cross(v12, v10);
+ vec3 n3 = cross(v13, v12);
+
+ float fac0 = dot(view_vec, n0);
+ float fac3 = dot(view_vec, n3);
+
+ /* If both adjacent verts are facing the camera the same way,
+ * then it isn't an outline edge. */
+ if (sign(fac0) == sign(fac3))
+ return;
+
+ /* Don't outline if concave edge. */
+ /* That would hide a lot of non usefull edge but it flickers badly.
+ * TODO revisit later... */
+ // if (dot(n0, v13) > 0.01)
+ // return;
+
+ gl_Position = pPos[1]; EmitVertex();
+ gl_Position = pPos[2]; EmitVertex();
+ EndPrimitive();
+}
diff --git a/source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl b/source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl
new file mode 100644
index 00000000000..ba824a7c007
--- /dev/null
+++ b/source/blender/draw/modes/shaders/object_outline_prepass_vert.glsl
@@ -0,0 +1,16 @@
+
+uniform mat4 ModelViewMatrix;
+uniform mat4 ModelViewProjectionMatrix;
+
+in vec3 pos;
+
+out vec4 pPos;
+out vec3 vPos;
+
+void main()
+{
+ vPos = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
+ pPos = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ /* Small bias to always be on top of the geom. */
+ pPos.z -= 1e-3;
+}