diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-10-30 21:07:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-10-30 21:07:49 +0300 |
commit | ffcf193653a64e93cac800156d25f63d9aa38c9b (patch) | |
tree | 344e5087f7bfce4dcbd3b9a52723a39d40d7fe18 | |
parent | 09416fe6e1359ba18b84972e11a4c2c11b671de6 (diff) |
UI: Make Wireframe size respect DPI settings
-rw-r--r-- | source/blender/draw/modes/overlay_mode.c | 5 | ||||
-rw-r--r-- | source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c index ba2bfc61ba6..a5c20033287 100644 --- a/source/blender/draw/modes/overlay_mode.c +++ b/source/blender/draw/modes/overlay_mode.c @@ -185,22 +185,27 @@ static void overlay_cache_init(void *vedata) { /* Wireframe */ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND; + float wire_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f; psl->flat_wireframe_pass = DRW_pass_create("Flat Object Wires", state | DRW_STATE_WRITE_DEPTH); psl->face_wireframe_full_pass = DRW_pass_create("All Face Wires", state); stl->g_data->sculpt_wires_full = DRW_shgroup_create(e_data.face_wireframe_sculpt_sh, psl->face_wireframe_full_pass); + DRW_shgroup_uniform_float_copy(stl->g_data->sculpt_wires_full, "wireSize", wire_size); DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.face_wireframe_sh, psl->face_wireframe_full_pass); + DRW_shgroup_uniform_float_copy(shgrp, "wireSize", wire_size); psl->face_wireframe_pass = DRW_pass_create("Face Wires", state); stl->g_data->sculpt_wires = DRW_shgroup_create(e_data.face_wireframe_sculpt_pretty_sh, psl->face_wireframe_pass); DRW_shgroup_uniform_vec2(stl->g_data->sculpt_wires, "wireStepParam", stl->g_data->wire_step_param, 1); + DRW_shgroup_uniform_float_copy(stl->g_data->sculpt_wires, "wireSize", wire_size); shgrp = DRW_shgroup_create(e_data.face_wireframe_pretty_sh, psl->face_wireframe_pass); DRW_shgroup_uniform_vec2(shgrp, "wireStepParam", stl->g_data->wire_step_param, 1); + DRW_shgroup_uniform_float_copy(shgrp, "wireSize", wire_size); /** * The wireframe threshold ranges from 0.0 to 1.0 diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl index 75bfe04aa8b..69af4858a48 100644 --- a/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl +++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl @@ -16,7 +16,7 @@ float min_v3(vec3 v) { return min(v.x, min(v.y, v.z)); } float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); } /* In pixels */ -const float wire_size = 0.0; /* Expands the core of the wire (part that is 100% wire color) */ +uniform float wireSize = 0.0; /* Expands the core of the wire (part that is 100% wire color) */ const float wire_smooth = 1.2; /* Smoothing distance after the 100% core. */ /* Alpha constants could be exposed in the future. */ @@ -41,7 +41,7 @@ void main() float fac = min_v3(abs(dist_to_edge)); # endif - fac = smoothstep(wire_size + wire_smooth, wire_size, fac); + fac = smoothstep(wireSize + wire_smooth, wireSize, fac); float facing_clamped = clamp((gl_FrontFacing) ? facing : -facing, 0.0, 1.0); |