[Bf-blender-cvs] [ffcf193653a] blender2.8: UI: Make Wireframe size respect DPI settings

Clément Foucault noreply at git.blender.org
Tue Oct 30 19:08:08 CET 2018


Commit: ffcf193653a64e93cac800156d25f63d9aa38c9b
Author: Clément Foucault
Date:   Tue Oct 30 19:07:27 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBffcf193653a64e93cac800156d25f63d9aa38c9b

UI: Make Wireframe size respect DPI settings

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

M	source/blender/draw/modes/overlay_mode.c
M	source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl

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

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);



More information about the Bf-blender-cvs mailing list