diff options
author | ianwill <wpgermano@gmail.com> | 2017-02-24 23:33:09 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2017-02-24 23:33:32 +0300 |
commit | bda0456933e87c2f623a8e4f980bf7cfc6b3982a (patch) | |
tree | 87375bc766b4c0866f6b4ad4c96544c74509ff12 /source/blender/gpu | |
parent | 1f453a8909527a95fedd597b4fdaab90c18712f9 (diff) |
OpenGL: wm_gesture uses new imm mode
D2376 by @ianwill, part of T49043
review by @merwin
Box select, circle select, etc. Introducing the dashed-line shader! See D2376 for more info.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl | 25 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl | 20 |
5 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index f4627231afc..2d82eb692ed 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -140,6 +140,8 @@ data_to_c_simple(shaders/gpu_shader_flat_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_flat_color_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_2D_line_dashed_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_2D_line_dashed_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_smooth_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_smooth_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_image_vert.glsl SRC) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 57309c2ebde..36a59102df8 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -136,6 +136,8 @@ typedef enum GPUBuiltinShader { GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_SMOOTH, GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR, GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR, + /* lines */ + GPU_SHADER_2D_LINE_DASHED_COLOR, /* lamp drawing */ GPU_SHADER_3D_GROUNDPOINT, GPU_SHADER_3D_GROUNDLINE, diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index a9a8a10cc79..4f5c5428508 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -98,6 +98,9 @@ extern char datatoc_gpu_shader_2D_point_uniform_size_smooth_vert_glsl[]; extern char datatoc_gpu_shader_2D_point_uniform_size_outline_smooth_vert_glsl[]; extern char datatoc_gpu_shader_2D_point_uniform_size_varying_color_outline_smooth_vert_glsl[]; +extern char datatoc_gpu_shader_2D_line_dashed_vert_glsl[]; +extern char datatoc_gpu_shader_2D_line_dashed_frag_glsl[]; + extern char datatoc_gpu_shader_edges_front_back_persp_vert_glsl[]; extern char datatoc_gpu_shader_edges_front_back_persp_geom_glsl[]; extern char datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl[]; @@ -705,6 +708,9 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_uniform_color_frag_glsl, datatoc_gpu_shader_3D_groundline_geom_glsl }, + [GPU_SHADER_2D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_2D_line_dashed_vert_glsl, + datatoc_gpu_shader_2D_line_dashed_frag_glsl }, + [GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] = { datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl, datatoc_gpu_shader_simple_lighting_frag_glsl}, diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl new file mode 100644 index 00000000000..85aab7e06ef --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl @@ -0,0 +1,25 @@ + +// Draw dashed lines, perforated in screen space. +// Based on a (3D) version by Mike Erwin. + +#if __VERSION__ == 120 + noperspective varying float distance_along_line; + #define fragColor gl_FragColor +#else + noperspective in float distance_along_line; + out vec4 fragColor; +#endif + +uniform float dash_width; +uniform float dash_width_on; +uniform vec4 color1; +uniform vec4 color2; + +void main() +{ + if (mod(distance_along_line, dash_width) <= dash_width_on) { + fragColor = color1; + } else { + fragColor = color2; + } +} 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 new file mode 100644 index 00000000000..e89b3262fab --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl @@ -0,0 +1,20 @@ + +// Draw dashed lines, perforated in screen space. +// Based on a (3D) version by Mike Erwin. + +#if __VERSION__ == 120 + attribute vec2 pos; + attribute vec2 line_origin; // = pos for one vertex of the line + noperspective varying float distance_along_line; +#else + in vec2 pos; + in vec2 line_origin; + noperspective out float distance_along_line; +#endif + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0); + + distance_along_line = distance(line_origin, pos); +} |