[Bf-blender-cvs] [050e91340da] blender2.8: Edit Mesh: Fix wire opacity when not rotating the view in Xray mode

Clément Foucault noreply at git.blender.org
Mon Nov 5 16:31:18 CET 2018


Commit: 050e91340da1b4d263b850bbe4e114379c2188cb
Author: Clément Foucault
Date:   Sun Nov 4 20:01:25 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB050e91340da1b4d263b850bbe4e114379c2188cb

Edit Mesh: Fix wire opacity when not rotating the view in Xray mode

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

M	source/blender/draw/modes/edit_mesh_mode.c
M	source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
M	source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl

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

diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index f5555063480..4ab3c1f992a 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -336,7 +336,7 @@ static void EDIT_MESH_engine_init(void *vedata)
 }
 
 static DRWPass *edit_mesh_create_overlay_pass(
-        float *face_alpha, float *edge_width_scale, int *data_mask, bool do_edges,
+        float *face_alpha, float *edge_width_scale, int *data_mask, bool do_edges, bool xray,
         DRWState statemod,
         DRWShadingGroup **r_face_shgrp, DRWShadingGroup **r_verts_shgrp, DRWShadingGroup **r_ledges_shgrp,
         DRWShadingGroup **r_lverts_shgrp, DRWShadingGroup **r_facedot_shgrp)
@@ -346,6 +346,7 @@ static DRWPass *edit_mesh_create_overlay_pass(
 	RegionView3D *rv3d = draw_ctx->rv3d;
 	Scene *scene = draw_ctx->scene;
 	ToolSettings *tsettings = scene->toolsettings;
+	const int fast_mode = rv3d->rflag & RV3D_NAVIGATING;
 
 	ledge_sh = EDIT_MESH_ensure_shader(tsettings, rv3d, false, true);
 	tri_sh = EDIT_MESH_ensure_shader(tsettings, rv3d, true, false);
@@ -361,6 +362,9 @@ static DRWPass *edit_mesh_create_overlay_pass(
 	DRW_shgroup_uniform_float(*r_face_shgrp, "edgeScale", edge_width_scale, 1);
 	DRW_shgroup_uniform_ivec4(*r_face_shgrp, "dataMask", data_mask, 1);
 	DRW_shgroup_uniform_bool_copy(*r_face_shgrp, "doEdges", do_edges);
+	if (!fast_mode) {
+		DRW_shgroup_uniform_bool_copy(*r_face_shgrp, "isXray", xray);
+	}
 
 	*r_ledges_shgrp = DRW_shgroup_create(ledge_sh, pass);
 	DRW_shgroup_uniform_block(*r_ledges_shgrp, "globalsBlock", globals_ubo);
@@ -512,7 +516,7 @@ static void EDIT_MESH_cache_init(void *vedata)
 
 	if (!stl->g_data->do_zbufclip) {
 		psl->edit_face_overlay = edit_mesh_create_overlay_pass(
-		        &face_mod, &stl->g_data->edge_width_scale, stl->g_data->data_mask, stl->g_data->do_edges,
+		        &face_mod, &stl->g_data->edge_width_scale, stl->g_data->data_mask, stl->g_data->do_edges, false,
 		        DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND,
 		        &stl->g_data->face_overlay_shgrp,
 		        &stl->g_data->verts_overlay_shgrp,
@@ -523,7 +527,7 @@ static void EDIT_MESH_cache_init(void *vedata)
 	else {
 		/* We render all wires with depth and opaque to a new fbo and blend the result based on depth values */
 		psl->edit_face_occluded = edit_mesh_create_overlay_pass(
-		        &zero, &stl->g_data->edge_width_scale, stl->g_data->data_mask, stl->g_data->do_edges,
+		        &zero, &stl->g_data->edge_width_scale, stl->g_data->data_mask, stl->g_data->do_edges, true,
 		        DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH,
 		        &stl->g_data->face_occluded_shgrp,
 		        &stl->g_data->verts_occluded_shgrp,
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
index 85a30041b27..7fa822bc697 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -4,6 +4,7 @@
 
 uniform float faceAlphaMod;
 uniform float edgeScale;
+uniform bool isXray = false;
 
 flat in vec3 edgesCrease;
 flat in vec3 edgesBweight;
@@ -31,9 +32,7 @@ out vec4 FragColor;
 #define LARGE_EDGE_SIZE 2.15
 
 /* Enough to visually fill gaps and not enough to mess the AA gradient too much. */
-#define EDGE_FIX_ALPHA 0.6
-
-/* Style Parameters in pixel */
+#define EDGE_FIX_ALPHA 0.67
 
 void distToEdgesAndPoints(out vec3 edges, out vec3 points)
 {
@@ -107,7 +106,7 @@ void main()
 
 			vec4 large_edge_color = EDIT_MESH_edge_color_outer(flag[v], (flag[0] & FACE_ACTIVE_) != 0, edgesCrease[v], edgesBweight[v]);
 #ifdef EDGE_FIX
-			large_edge_color *= EDGE_FIX_ALPHA;
+			large_edge_color *= isXray ? 1.0 : EDGE_FIX_ALPHA;
 #endif
 			if (large_edge_color.a != 0.0) {
 				colorDistEdge(large_edge_color, largeEdge);
@@ -122,13 +121,13 @@ void main()
 #ifdef VERTEX_SELECTION
 			vec4 inner_edge_color = vec4(vertexColor, 1.0);
 #  ifdef EDGE_FIX
-			inner_edge_color *= EDGE_FIX_ALPHA;
+			inner_edge_color *= isXray ? 1.0 : EDGE_FIX_ALPHA;
 #  endif
 			colorDistEdge(vec4(vertexColor, 1.0), innerEdge);
 #else
 			vec4 inner_edge_color = EDIT_MESH_edge_color_inner(flag[v], (flag[0] & FACE_ACTIVE_) != 0);
 #  ifdef EDGE_FIX
-			inner_edge_color *= EDGE_FIX_ALPHA;
+			inner_edge_color *= isXray ? 1.0 : EDGE_FIX_ALPHA;
 #  endif
 			colorDistEdge(inner_edge_color, innerEdge);
 #endif
@@ -148,7 +147,7 @@ void main()
 			point_color = ((flag[v] & EDGE_VERTEX_SELECTED) != 0) ? colorVertexSelect : point_color;
 			point_color = ((flag[v] & EDGE_VERTEX_ACTIVE) != 0) ? vec4(colorEditMeshActive.xyz, 1.0) : point_color;
 #  ifdef EDGE_FIX
-			point_color.a *= EDGE_FIX_ALPHA;
+			point_color *= isXray ? 1.0 : EDGE_FIX_ALPHA;
 #  endif
 			colorDist(point_color, size);
 		}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
index 0d2ff4d2008..e9adc38ea27 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
@@ -13,6 +13,7 @@ layout(triangle_strip, max_vertices=12) out;
 
 uniform mat4 ProjectionMatrix;
 uniform vec2 viewportSize;
+uniform bool isXray = false;
 
 in vec4 pPos[];
 in ivec4 vData[];
@@ -181,7 +182,7 @@ void main()
 
 	/* Do face triangle */
 	faceColor = fcol;
-	flag = eflag;
+	flag = (isXray) ? ivec3(0) : eflag;
 	doVertex(2);
 	faceColor.a = 0.0; /* to not let face color bleed */



More information about the Bf-blender-cvs mailing list