diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-04-24 00:05:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-04-24 00:07:48 +0300 |
commit | d712f1f83af881be536ec0d183b7d3025c172684 (patch) | |
tree | eabecb450ce2d4697468d2758df28fd990c14ed6 /source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c | |
parent | d0ff3434cffa2e056e4f191ead21226f32ea8c15 (diff) |
GPU: Add Polyline shader (wide line emulation)
This new shader is able to emulate smooth wide lines drawing using a
geometry shader.
This shader needs viewportSize and lineWidth uniforms to be set.
There is multiple variants to replace the usage of wide lines for most
shaders.
This patch only fix the gizmo_types files and the navigation gizmo.
Other areas could be fixed afterward, I just limited the patch size.
Fix T57570.
Reviewed By: billreynish
Differential Revision: https://developer.blender.org/D7487
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index a8e8d8cee96..3301e28c90c 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -197,8 +197,8 @@ static void axis_geom_draw(const wmGizmo *gz, const bool select, const struct AxisDrawInfo *draw_info) { - - GPU_line_width(gz->line_width); + float viewport[4]; + GPU_viewport_size_get_f(viewport); GPUVertFormat *format = immVertexFormat(); const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); @@ -341,8 +341,13 @@ static void axis_geom_draw(const wmGizmo *gz, /* Axis Line. */ if (is_pos) { float v_start[3]; - GPU_line_width(2.0f); + immUnbindProgram(); + + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + immUniform2fv("viewportSize", &viewport[2]); + immUniform1f("lineWidth", 2.0f * U.pixelsize); immUniformColor4fv(is_pos_color ? color_current : color_current_fade); + immBegin(GPU_PRIM_LINES, 2); if (axis_align == -1) { zero_v3(v_start); @@ -358,6 +363,10 @@ static void axis_geom_draw(const wmGizmo *gz, immVertex3fv(pos_id, v_start); immVertex3fv(pos_id, v_final); immEnd(); + + immUnbindProgram(); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); } /* Axis Ball. */ |