Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl10
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c7
2 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
index 7b4207142e6..94e8de4537b 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
@@ -3,6 +3,7 @@
// Based on a (3D) version by Mike Erwin.
uniform mat4 ModelViewProjectionMatrix;
+uniform float view_scale;
#if __VERSION__ == 120
attribute vec2 pos;
@@ -18,5 +19,12 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
- distance_along_line = distance(line_origin, pos);
+ distance_along_line = distance(line_origin, pos) * view_scale;
+
+ /* Another solution would be to compute line_origin in fragment coordinate, and then compute distance
+ * in fragment shader, but we'd need opengl window size for that...
+ * vec4 point = ModelViewProjectionMatrix * vec4(line_origin, 0.0, 1.0);
+ * ref_point = (point.xy / point.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
+ * ref_point = ref_point * window_size;
+ */
}
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);