mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user