render/pass: implement antialiasing for fractional coordinates

Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
This commit is contained in:
Loukas Agorgianitis 2026-01-08 22:40:20 +02:00
parent 5a49f2ae14
commit e92d8a7a53
No known key found for this signature in database
GPG key ID: DDC6FA7D5BB332E6
11 changed files with 170 additions and 20 deletions

View file

@ -3,8 +3,20 @@
layout(location = 0) out vec4 out_color;
layout(push_constant) uniform UBO {
layout(offset = 80) vec4 color;
vec4 dst_bounds; // x, y, x+width, y+height in output coordinates
} data;
void main() {
out_color = data.color;
float compute_coverage() {
vec4 d = vec4(
gl_FragCoord.x - data.dst_bounds.x,
gl_FragCoord.y - data.dst_bounds.y,
data.dst_bounds.z - gl_FragCoord.x,
data.dst_bounds.w - gl_FragCoord.y
);
vec4 cov = clamp(d + 0.5, 0.0, 1.0);
return min(min(cov.x, cov.y), min(cov.z, cov.w));
}
void main() {
out_color = data.color * compute_coverage();
}