[Bf-blender-cvs] [043c90fdcd] blender2.8: Edit Mode overlay: fast navigate

Clément Foucault noreply at git.blender.org
Thu Mar 2 01:10:44 CET 2017


Commit: 043c90fdcda7631edf6464ed86041d1cf62444fc
Author: Clément Foucault
Date:   Wed Mar 1 14:08:58 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB043c90fdcda7631edf6464ed86041d1cf62444fc

Edit Mode overlay: fast navigate

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

M	source/blender/draw/modes/edit_mesh_mode.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/gpu/GPU_shader.h
M	source/blender/gpu/intern/gpu_shader.c
M	source/blender/gpu/shaders/gpu_shader_edit_overlay_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_edit_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 7fcbed5c9b..dbb65835db 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -27,6 +27,7 @@
 #include "DRW_render.h"
 
 #include "GPU_shader.h"
+#include "DNA_view3d_types.h"
 
 #include "draw_mode_pass.h"
 
@@ -50,10 +51,15 @@ void EDIT_MESH_cache_init(void)
 {
 	EDIT_MESH_PassList *psl = DRW_mode_pass_list_get();
 	static struct GPUShader *depth_sh;
-	static struct GPUShader *over_tri_sh, *over_vert_sh, *over_edge_sh;
+	static struct GPUShader *over_tri_sh, *over_vert_sh, *over_edge_sh, *over_tri_fast_sh;
+
+	const struct bContext *C = DRW_get_context();
+	struct RegionView3D *rv3d = CTX_wm_region_view3d(C);
 
 	if (!depth_sh)
 		depth_sh = DRW_shader_create_3D_depth_only();
+	if (!over_tri_fast_sh)
+		over_tri_fast_sh = GPU_shader_get_builtin_shader(GPU_SHADER_EDGES_OVERLAY_EDIT_TRI_FAST);
 	if (!over_tri_sh)
 		over_tri_sh = GPU_shader_get_builtin_shader(GPU_SHADER_EDGES_OVERLAY_EDIT_TRI);
 	if (!over_edge_sh)
@@ -65,7 +71,10 @@ void EDIT_MESH_cache_init(void)
 	depth_shgrp_hidden_wire = DRW_shgroup_create(depth_sh, psl->depth_pass_hidden_wire);
 
 	psl->edit_face_overlay_pass = DRW_pass_create("Edit Mesh Face Overlay Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND);
-	face_overlay_shgrp = DRW_shgroup_create(over_tri_sh, psl->edit_face_overlay_pass);
+	if ((rv3d->rflag & RV3D_NAVIGATING) != 0)
+		face_overlay_shgrp = DRW_shgroup_create(over_tri_fast_sh, psl->edit_face_overlay_pass);
+	else
+		face_overlay_shgrp = DRW_shgroup_create(over_tri_sh, psl->edit_face_overlay_pass);
 	ledges_overlay_shgrp = DRW_shgroup_create(over_edge_sh, psl->edit_face_overlay_pass);
 	lverts_overlay_shgrp = DRW_shgroup_create(over_vert_sh, psl->edit_face_overlay_pass);
 	DRW_shgroup_uniform_vec2(face_overlay_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 1047eeec5e..53d56e0f53 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -819,8 +819,9 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
 static void viewops_data_free(bContext *C, wmOperator *op)
 {
 	ARegion *ar;
+#if 0
 	Paint *p = BKE_paint_get_active_from_context(C);
-
+#endif
 	if (op->customdata) {
 		ViewOpsData *vod = op->customdata;
 		ar = vod->ar;
@@ -836,7 +837,9 @@ static void viewops_data_free(bContext *C, wmOperator *op)
 		ar = CTX_wm_region(C);
 	}
 
+#if 0
 	if (p && (p->flags & PAINT_FAST_NAVIGATE))
+#endif
 		ED_region_tag_redraw(ar);
 }
 /** \} */
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 55fa474922..2488d26583 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -101,6 +101,7 @@ typedef enum GPUBuiltinShader {
 	GPU_SHADER_EDGES_FRONT_BACK_ORTHO,
 	GPU_SHADER_EDGES_OVERLAY_SIMPLE,
 	GPU_SHADER_EDGES_OVERLAY_EDIT_TRI,
+	GPU_SHADER_EDGES_OVERLAY_EDIT_TRI_FAST,
 	GPU_SHADER_EDGES_OVERLAY_EDIT_VERT,
 	GPU_SHADER_EDGES_OVERLAY_EDIT_EDGE,
 	GPU_SHADER_EDGES_OVERLAY,
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index c633fd0835..2e59030222 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -675,6 +675,9 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
 		[GPU_SHADER_EDGES_OVERLAY_EDIT_TRI] = { datatoc_gpu_shader_edit_overlay_vert_glsl,
 		                                        datatoc_gpu_shader_edit_overlay_frag_glsl,
 		                                        datatoc_gpu_shader_edit_overlay_geom_tri_glsl },
+		[GPU_SHADER_EDGES_OVERLAY_EDIT_TRI_FAST] = { datatoc_gpu_shader_edit_overlay_vert_glsl,
+		                                             datatoc_gpu_shader_edit_overlay_frag_glsl,
+		                                             datatoc_gpu_shader_edit_overlay_geom_tri_glsl },
 		[GPU_SHADER_EDGES_OVERLAY_EDIT_EDGE] = { datatoc_gpu_shader_edit_overlay_vert_glsl,
 		                                         datatoc_gpu_shader_edit_overlay_frag_glsl,
 		                                         datatoc_gpu_shader_edit_overlay_geom_edge_glsl },
@@ -775,6 +778,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
 		/* just a few special cases */
 		const char *defines = (shader == GPU_SHADER_SMOKE_COBA) ? "#define USE_COBA;\n" :
 		                      (shader == GPU_SHADER_SIMPLE_LIGHTING) ? "#define USE_NORMALS;\n" :
+		                      (shader == GPU_SHADER_EDGES_OVERLAY_EDIT_TRI) ? "#define EDGE_FIX;\n" :
 		                      (shader == GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR) ? "#define USE_INSTANCE_COLOR;\n" : NULL;
 
 		const GPUShaderStages *stages = builtin_shader_stages + shader;
diff --git a/source/blender/gpu/shaders/gpu_shader_edit_overlay_frag.glsl b/source/blender/gpu/shaders/gpu_shader_edit_overlay_frag.glsl
index dcee761650..e784c5eaba 100644
--- a/source/blender/gpu/shaders/gpu_shader_edit_overlay_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_edit_overlay_frag.glsl
@@ -99,7 +99,7 @@ float getVertexSize(int v)
 
 void colorDist(vec4 color, float width, inout float dist)
 {
-	FragColor = mix(color, FragColor, smoothstep(0.0, transitionWidth, dist));
+	FragColor = (dist - transitionWidth < 0) ? color : FragColor;
 	dist += width;
 }
 
@@ -191,4 +191,7 @@ void main()
 		else
 			colorDist(vec4(0.0, 0.0, 0.0, 1.0), vertexWidth, size);
 	}
+
+	/* don't write depth if not opaque */
+	if (FragColor.a == 0.0)	discard;
 }
diff --git a/source/blender/gpu/shaders/gpu_shader_edit_overlay_geom_tri.glsl b/source/blender/gpu/shaders/gpu_shader_edit_overlay_geom_tri.glsl
index f3966b40a6..a6f4a11db5 100644
--- a/source/blender/gpu/shaders/gpu_shader_edit_overlay_geom_tri.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_edit_overlay_geom_tri.glsl
@@ -5,7 +5,6 @@
 /* This shader follows the principles of
  * http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf */
 
-//#define EDGE_FIX
 layout(triangles) in;
 
 #ifdef EDGE_FIX




More information about the Bf-blender-cvs mailing list