[Bf-blender-cvs] [998b680e5bc] master: UI: Widget: Add conservative raster to avoid cut widget borders

Clément Foucault noreply at git.blender.org
Tue Sep 1 16:08:52 CEST 2020


Commit: 998b680e5bc745721737f321fc1fad95875ca7bb
Author: Clément Foucault
Date:   Tue Sep 1 15:44:53 2020 +0200
Branches: master
https://developer.blender.org/rB998b680e5bc745721737f321fc1fad95875ca7bb

UI: Widget: Add conservative raster to avoid cut widget borders

This avoids incorrect AA when the widget is not perfectly alligned with the
pixel grid.

===================================================================

M	source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl

===================================================================

diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
index d15f48c8f8a..fb512a1f00e 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
@@ -57,9 +57,14 @@ in float dummy;
 
 vec2 do_widget(void)
 {
+  /* Offset to avoid loosing pixels (mimics conservative rasterization). */
+  const vec2 ofs = vec2(0.5, -0.5);
   lineWidth = abs(rect.x - recti.x);
   vec2 emboss_ofs = vec2(0.0, -lineWidth);
-  vec2 v_pos[4] = vec2[4](rect.xz + emboss_ofs, rect.xw, rect.yz + emboss_ofs, rect.yw);
+  vec2 v_pos[4] = vec2[4](rect.xz + emboss_ofs + ofs.yy,
+                          rect.xw + ofs.yx,
+                          rect.yz + emboss_ofs + ofs.xy,
+                          rect.yw + ofs.xx);
   vec2 pos = v_pos[gl_VertexID];
 
   uvInterp = pos - rect.xz;



More information about the Bf-blender-cvs mailing list