From 215638e9fcf589c81273739c0b92e9e142e1313c Mon Sep 17 00:00:00 2001 From: Yonatan Maor Date: Thu, 27 Apr 2023 07:42:12 +0300 Subject: [PATCH 1/4] Fix #107038: Added anti-aliasing to transform constraints Transform constraints were being drawn on screen without anti-aliasing --- source/blender/editors/transform/transform_constraints.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 9b92a37abdf..a5eab2f8e7d 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -781,12 +781,17 @@ static void drawLine( immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ubv(col2); + + GPU_line_smooth(true); + GPU_blend(GPU_BLEND_ALPHA); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, v1); immVertex3fv(pos, v2); immEnd(); immUnbindProgram(); + GPU_line_smooth(false); GPU_matrix_pop(); } -- 2.30.2 From 3d296f664fc9885b455b83b2d3dd808c63e9c177 Mon Sep 17 00:00:00 2001 From: Yonatan Maor Date: Thu, 27 Apr 2023 09:16:26 +0300 Subject: [PATCH 2/4] Removed unnecessary line from the issue fix --- source/blender/editors/transform/transform_constraints.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index a5eab2f8e7d..9162a072772 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -781,7 +781,6 @@ static void drawLine( immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ubv(col2); - GPU_line_smooth(true); GPU_blend(GPU_BLEND_ALPHA); -- 2.30.2 From f11fb1a003f395e109936d79642f5d542e4a5686 Mon Sep 17 00:00:00 2001 From: Yonatan Maor Date: Fri, 28 Apr 2023 06:50:06 +0300 Subject: [PATCH 3/4] Corrected transform line anti-aliasing to be portable to MacOS and Metal backend --- .../editors/transform/transform_constraints.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 9162a072772..7c6ac2df2bf 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -778,19 +778,23 @@ static void drawLine( uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor3ubv(col2); - - GPU_line_smooth(true); + // immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + float viewport[4]; + GPU_viewport_size_get_f(viewport); GPU_blend(GPU_BLEND_ALPHA); + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + immUniform2fv("viewportSize", &viewport[2]); + immUniform1f("lineWidth", U.pixelsize * 2.0f); + + immUniformColor3ubv(col2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, v1); immVertex3fv(pos, v2); immEnd(); immUnbindProgram(); - GPU_line_smooth(false); GPU_matrix_pop(); } -- 2.30.2 From d891f4311da9c29237f0ba497b2c4dcd1e887320 Mon Sep 17 00:00:00 2001 From: Yonatan Maor Date: Fri, 28 Apr 2023 16:26:28 +0300 Subject: [PATCH 4/4] Removed commented lines from transform_constraints.c --- source/blender/editors/transform/transform_constraints.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 7c6ac2df2bf..25034e0bb08 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -778,7 +778,6 @@ static void drawLine( uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - // immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); float viewport[4]; GPU_viewport_size_get_f(viewport); GPU_blend(GPU_BLEND_ALPHA); -- 2.30.2