gtk/gsk/vulkan/resources/rounded-rect.frag.glsl
Benjamin Otte 1be21a33d9 vulkan: Rewrite rounded rectangle to use SDF distance
We can use this to properly compute distance in scaled situations.
We also now compute coverage with (imperfect) antialiasing.
2023-06-04 19:42:00 +02:00

18 lines
359 B
GLSL

#ifndef _ROUNDED_RECT_FRAG_
#define _ROUNDED_RECT_FRAG_
#include "rounded-rect.glsl"
float
rounded_rect_coverage (RoundedRect r, vec2 p)
{
vec2 fw = abs (fwidth (p));
float distance_scale = max (fw.x, fw.y);
float distance = rounded_rect_distance (r, p) / distance_scale;
float coverage = 0.5 - distance;
return clamp (coverage, 0, 1);
}
#endif