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.
This commit is contained in:
Clément Foucault 2020-09-01 15:44:53 +02:00
parent 31004ef48e
commit 998b680e5b
1 changed files with 6 additions and 1 deletions

View File

@ -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;