2020-02-03 10:52:39 -08:00
|
|
|
#version 330
|
|
|
|
|
|
|
|
in vec4 color;
|
2021-11-01 13:05:13 -07:00
|
|
|
in float fill_all; // Either 0 or 1
|
2020-02-03 10:52:39 -08:00
|
|
|
in float uv_anti_alias_width;
|
|
|
|
|
2020-06-03 17:10:33 -07:00
|
|
|
in float orientation;
|
2020-02-03 10:52:39 -08:00
|
|
|
in vec2 uv_coords;
|
2023-01-10 08:54:02 -08:00
|
|
|
in float is_linear;
|
2020-02-03 10:52:39 -08:00
|
|
|
|
|
|
|
out vec4 frag_color;
|
|
|
|
|
2023-01-10 08:54:02 -08:00
|
|
|
float sdf(float x0, float y0){
|
|
|
|
if(bool(is_linear)) return abs(y0);
|
2023-01-09 19:54:09 -08:00
|
|
|
|
|
|
|
float Fxy = y0 - x0 * x0;
|
2023-01-10 08:54:02 -08:00
|
|
|
if(orientation * Fxy >= 0) return 0.0;
|
|
|
|
|
2023-01-09 19:54:09 -08:00
|
|
|
return abs(Fxy) / sqrt(1 + 4 * x0 * x0);
|
2020-02-03 10:52:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
if (color.a == 0) discard;
|
2020-06-06 16:55:56 -07:00
|
|
|
frag_color = color;
|
2023-01-10 09:49:51 -08:00
|
|
|
if (bool(fill_all)) return;
|
2023-01-10 08:54:02 -08:00
|
|
|
float dist = sdf(uv_coords.x, uv_coords.y);
|
|
|
|
frag_color.a *= smoothstep(1, 0, dist / uv_anti_alias_width);
|
2020-03-30 20:26:06 +02:00
|
|
|
}
|