[Bf-blender-cvs] [fdc93183600] soc-2021-uv-edge-select-support: UV: Drawing selected edges

Siddhartha Jejurkar noreply at git.blender.org
Fri Sep 10 11:51:34 CEST 2021


Commit: fdc931836004b2d8df6870be470e4b8d4596c4ca
Author: Siddhartha Jejurkar
Date:   Fri Sep 10 14:55:02 2021 +0530
Branches: soc-2021-uv-edge-select-support
https://developer.blender.org/rBfdc931836004b2d8df6870be470e4b8d4596c4ca

UV: Drawing selected edges

* Changes vertex count for UV edge polygon from 4 to 6 in the geometry
  shader
* Edge center for a selected edge will not be highlighted if the edge is
  not selected. This new behavior provides a visual aid to the user that
  helps in identifying selected and unselected UV edges

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

M	source/blender/draw/engines/overlay/shaders/edit_uv_edges_geom.glsl
M	source/blender/draw/engines/overlay/shaders/edit_uv_edges_vert.glsl

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

diff --git a/source/blender/draw/engines/overlay/shaders/edit_uv_edges_geom.glsl b/source/blender/draw/engines/overlay/shaders/edit_uv_edges_geom.glsl
index 4f8d553a220..2b4ddaa52f3 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_uv_edges_geom.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_uv_edges_geom.glsl
@@ -2,9 +2,10 @@
 #pragma BLENDER_REQUIRE(common_overlay_lib.glsl)
 
 layout(lines) in;
-layout(triangle_strip, max_vertices = 4) out;
+layout(triangle_strip, max_vertices = 6) out;
 
 in float selectionFac[2];
+in float edgeSelectionFac[2];
 flat in vec2 stippleStart[2];
 noperspective in vec2 stipplePos[2];
 
@@ -35,6 +36,12 @@ void main()
   vec2 ss_pos[2];
   vec4 pos0 = gl_in[0].gl_Position;
   vec4 pos1 = gl_in[1].gl_Position;
+  /* TODO(verify): Calculating edge-center in clip space might cause errors due to precision loss?? */
+  vec4 edgeCenter = (pos0 + pos1) / 2.0;
+  bool is_edge_selected = edgeSelectionFac[0] == 1.0;
+  /* Depth value as specified in vertex shader */
+  edgeCenter.z = is_edge_selected ? 0.25 : 0.35;
+
   ss_pos[0] = pos0.xy / pos0.w;
   ss_pos[1] = pos1.xy / pos1.w;
 
@@ -54,8 +61,14 @@ void main()
   vec2 line_perp = vec2(-line_dir.y, line_dir.x);
   vec2 edge_ofs = line_perp * sizeViewportInv * ceil(half_size);
 
+  vec2 stippleStartCenter, stipplePosCenter;
+  /* TODO(stipple pattern): Probable incorrect implementation - used as specified in vertex shader */
+  stippleStartCenter = stipplePosCenter = 500.0 + 500.0 * (edgeCenter.xy / edgeCenter.w);
+
   do_vertex(pos0, selectionFac[0], stippleStart[0], stipplePos[0], half_size, edge_ofs.xy);
   do_vertex(pos0, selectionFac[0], stippleStart[0], stipplePos[0], -half_size, -edge_ofs.xy);
+  do_vertex(edgeCenter, edgeSelectionFac[0], stippleStartCenter, stipplePosCenter, half_size, edge_ofs.xy);
+  do_vertex(edgeCenter, edgeSelectionFac[0], stippleStartCenter, stipplePosCenter, -half_size, -edge_ofs.xy);
   do_vertex(pos1, selectionFac[1], stippleStart[1], stipplePos[1], half_size, edge_ofs.xy);
   do_vertex(pos1, selectionFac[1], stippleStart[1], stipplePos[1], -half_size, -edge_ofs.xy);
 
diff --git a/source/blender/draw/engines/overlay/shaders/edit_uv_edges_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_uv_edges_vert.glsl
index 7627a287a05..3b00fd7aafe 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_uv_edges_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_uv_edges_vert.glsl
@@ -6,6 +6,7 @@ in vec2 au;
 in int flag;
 
 out float selectionFac;
+out float edgeSelectionFac;
 noperspective out vec2 stipplePos;
 flat out vec2 stippleStart;
 
@@ -20,7 +21,9 @@ void main()
                    half_pixel_offset;
 
   bool is_select = (flag & VERT_UV_SELECT) != 0;
+  bool is_edge_selected = (flag & EDGE_UV_SELECT) != 0;
   selectionFac = is_select ? 1.0 : 0.0;
+  edgeSelectionFac = is_edge_selected ? 1.0 : 0.0;
   /* Move selected edges to the top
    * Vertices are between 0.0 and 0.2, Edges between 0.2 and 0.4
    * actual pixels are at 0.75, 1.0 is used for the background. */



More information about the Bf-blender-cvs mailing list