shaders: Optimize rounding_alpha() a little
Browse files at this commitd020d986ed85707f72aecea78ef2235fafdcdbe1Parent: 5abeb921 changed file +5 -2
src/render_helpers/shaders/rounding_alpha.fragmodified+5 -2
| @@ -19,6 +19,9 @@ float niri_rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) { | |||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | float dist = distance(coords, center); | 21 | float dist = distance(coords, center); |
| 22 | - float half_px = 0.5 / niri_scale; | 22 | + |
| 23 | - return 1.0 - smoothstep(radius - half_px, radius + half_px, dist); | 23 | + // Manual smoothstep() between radius - half_px and radius + half_px |
| 24 | + // to avoid a division in clamp(). | ||
| 25 | + float t = clamp((dist - radius) * niri_scale + 0.5, 0.0, 1.0); | ||
| 26 | + return 1.0 - t * t * (3.0 - 2.0 * t); | ||
| 24 | } | 27 | } |