From d712f1f83af881be536ec0d183b7d3025c172684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 23 Apr 2020 23:05:39 +0200 Subject: 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 --- .../editors/space_view3d/view3d_gizmo_navigate_type.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_view3d') 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. */ -- cgit v1.2.3