shaders: Optimize rounding_alpha() a little

Simplified clamping exploiting half_px + half_px = 1.0 / niri_scale.

Makes the resize shader fit on a Eee PC ALU.
This commit is contained in:
Ivan Molodetskikh
2026-02-05 23:23:41 +03:00
parent 5abeb923de
commit d020d986ed
@@ -19,6 +19,9 @@ float niri_rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) {
}
float dist = distance(coords, center);
float half_px = 0.5 / niri_scale;
return 1.0 - smoothstep(radius - half_px, radius + half_px, dist);
// Manual smoothstep() between radius - half_px and radius + half_px
// to avoid a division in clamp().
float t = clamp((dist - radius) * niri_scale + 0.5, 0.0, 1.0);
return 1.0 - t * t * (3.0 - 2.0 * t);
}