diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-08-30 08:45:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-08-30 08:54:23 +0300 |
commit | 7dd24ba6e84cf48b0d1ce60abaedfcd94cd5d5f6 (patch) | |
tree | fa3db13e3d6071b8778d5497bae3f0a4ecff1969 /source/blender/draw | |
parent | 84cc111e8b16ddcba4dde70122015c845eeefc77 (diff) |
3D View: use thicker edges when in edge-mode
Without this there is no visual differentiation between face/edge mode.
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/modes/edit_mesh_mode.c | 10 | ||||
-rw-r--r-- | source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 254afeb59ab..6c86f008e3d 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -316,6 +316,8 @@ static DRWPass *edit_mesh_create_overlay_pass( DRWShadingGroup **r_face_shgrp, DRWShadingGroup **r_ledges_shgrp, DRWShadingGroup **r_lverts_shgrp, DRWShadingGroup **r_facedot_shgrp) { + static float edge_width_scale; + GPUShader *tri_sh, *ledge_sh; const DRWContextState *draw_ctx = DRW_context_state_get(); RegionView3D *rv3d = draw_ctx->rv3d; @@ -329,24 +331,32 @@ static DRWPass *edit_mesh_create_overlay_pass( "Edit Mesh Face Overlay Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_POINT | statemod); + + /* Applies on top of the theme edge width, so edge-mode can have thick edges. */ + edge_width_scale = (tsettings->selectmode & (SCE_SELECT_EDGE)) ? 1.75f : 1.0f; + *r_face_shgrp = DRW_shgroup_create(tri_sh, pass); DRW_shgroup_uniform_block(*r_face_shgrp, "globalsBlock", globals_ubo); DRW_shgroup_uniform_vec2(*r_face_shgrp, "viewportSize", DRW_viewport_size_get(), 1); DRW_shgroup_uniform_float(*r_face_shgrp, "faceAlphaMod", faceAlpha, 1); + DRW_shgroup_uniform_float(*r_face_shgrp, "edgeScale", &edge_width_scale, 1); *r_ledges_shgrp = DRW_shgroup_create(ledge_sh, pass); DRW_shgroup_uniform_block(*r_ledges_shgrp, "globalsBlock", globals_ubo); DRW_shgroup_uniform_vec2(*r_ledges_shgrp, "viewportSize", DRW_viewport_size_get(), 1); + DRW_shgroup_uniform_float(*r_ledges_shgrp, "edgeScale", &edge_width_scale, 1); if ((tsettings->selectmode & (SCE_SELECT_VERTEX)) != 0) { *r_lverts_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, pass); DRW_shgroup_uniform_block(*r_lverts_shgrp, "globalsBlock", globals_ubo); DRW_shgroup_uniform_vec2(*r_lverts_shgrp, "viewportSize", DRW_viewport_size_get(), 1); + DRW_shgroup_uniform_float(*r_lverts_shgrp, "edgeScale", &edge_width_scale, 1); } if ((tsettings->selectmode & (SCE_SELECT_FACE)) != 0) { *r_facedot_shgrp = DRW_shgroup_create(e_data.overlay_facedot_sh, pass); DRW_shgroup_uniform_block(*r_facedot_shgrp, "globalsBlock", globals_ubo); + DRW_shgroup_uniform_float(*r_facedot_shgrp, "edgeScale", &edge_width_scale, 1); } return pass; 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 fe9062a8d50..6551fa81c21 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl @@ -10,6 +10,7 @@ * TODO Refine the range to only affect GPUs. */ uniform float faceAlphaMod; +uniform float edgeScale; flat in vec3 edgesCrease; flat in vec3 edgesBweight; @@ -74,10 +75,12 @@ void main() FragColor.a *= faceAlphaMod; /* Edges */ + float sizeEdgeFinal = sizeEdge * edgeScale; + for (int v = 0; v < 3; ++v) { if ((flag[v] & EDGE_EXISTS) != 0) { /* Outer large edge */ - float largeEdge = e[v] - sizeEdge * LARGE_EDGE_SIZE; + float largeEdge = e[v] - sizeEdgeFinal * LARGE_EDGE_SIZE; vec4 large_edge_color = EDIT_MESH_edge_color_outer(flag[v], (flag[0]& FACE_ACTIVE) != 0, edgesCrease[v], edgesBweight[v]); @@ -86,7 +89,7 @@ void main() } /* Inner thin edge */ - float innerEdge = e[v] - sizeEdge; + float innerEdge = e[v] - sizeEdgeFinal; #ifdef ANTI_ALIASING innerEdge += 0.4; #endif |