mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-14 04:28:22 -05:00
render/pass: implement antialiasing for fractional coordinates
Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
This commit is contained in:
parent
5a49f2ae14
commit
e92d8a7a53
11 changed files with 170 additions and 20 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ layout(push_constant, row_major) uniform UBO {
|
|||
layout(offset = 80) mat4 matrix;
|
||||
float alpha;
|
||||
float luminance_multiplier;
|
||||
vec2 _pad; // padding for vec4 alignment
|
||||
vec4 dst_bounds; // x, y, x+width, y+height in output coordinates
|
||||
} data;
|
||||
|
||||
layout (constant_id = 0) const int TEXTURE_TRANSFORM = 0;
|
||||
|
|
@ -57,6 +59,17 @@ vec3 bt1886_color_to_linear(vec3 color) {
|
|||
return (L - Lmin) / (Lmax - Lmin);
|
||||
}
|
||||
|
||||
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() {
|
||||
vec4 in_color = textureLod(tex, uv, 0);
|
||||
|
||||
|
|
@ -89,5 +102,5 @@ void main() {
|
|||
// Back to pre-multiplied alpha
|
||||
out_color = vec4(rgb * alpha, alpha);
|
||||
|
||||
out_color *= data.alpha;
|
||||
out_color *= data.alpha * compute_coverage();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue