From 621b8bdf86412786e561a5e25fb7583ed61e2b0d Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 26 Apr 2017 12:04:35 +0200 Subject: Tweak 2D line dashed shader to take a scale parameter. Even though in some cases this does not seems useful, in others (like zommed 2D views) we have to correct MVP matrix scaling to get fixed dashes size. Note that we could do that differently (commented about it in shader), would also have been cleaner to extract that MVP scale from within the shader, but there does not seem to be a way to initialize uniform values from within a shader, and would rather avoid recomputing the scale for every run (especially since 3DViewport does not need it e.g.). Part of D2647. --- source/blender/windowmanager/intern/wm_gesture.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/windowmanager/intern') diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 84c98f4071d..38b843772ab 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -178,6 +178,7 @@ static void wm_gesture_draw_line(wmGesture *gt) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + immUniform1f("view_scale", 1.0f); immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f); immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f); immUniform1f("dash_width", 8.0f); @@ -240,6 +241,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + immUniform1f("view_scale", 1.0f); immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f); immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f); immUniform1f("dash_width", 8.0f); @@ -301,6 +303,7 @@ static void wm_gesture_draw_circle(wmGesture *gt) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + immUniform1f("view_scale", 1.0f); immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f); immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f); immUniform1f("dash_width", 4.0f); @@ -401,7 +404,7 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled) numverts++; } - /* Nothing to drawe, do early output. */ + /* Nothing to draw, do early output. */ if (numverts < 2) { return; } @@ -412,6 +415,7 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + immUniform1f("view_scale", 1.0f); immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f); immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f); immUniform1f("dash_width", 2.0f); @@ -456,6 +460,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + immUniform1f("view_scale", 1.0f); immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f); immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f); immUniform1f("dash_width", 8.0f); -- cgit v1.2.3