mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-25 01:40:56 -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
|
|
@ -7,7 +7,19 @@ precision mediump float;
|
|||
varying vec4 v_color;
|
||||
varying vec2 v_texcoord;
|
||||
uniform vec4 color;
|
||||
uniform vec4 dst_bounds; // x, y, x+width, y+height in output coordinates
|
||||
|
||||
float compute_coverage() {
|
||||
vec4 d = vec4(
|
||||
gl_FragCoord.x - dst_bounds.x,
|
||||
gl_FragCoord.y - dst_bounds.y,
|
||||
dst_bounds.z - gl_FragCoord.x,
|
||||
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() {
|
||||
gl_FragColor = color;
|
||||
gl_FragColor = color * compute_coverage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,19 @@ precision mediump float;
|
|||
varying vec2 v_texcoord;
|
||||
uniform samplerExternalOES texture0;
|
||||
uniform float alpha;
|
||||
uniform vec4 dst_bounds; // x, y, x+width, y+height in output coordinates
|
||||
|
||||
float compute_coverage() {
|
||||
vec4 d = vec4(
|
||||
gl_FragCoord.x - dst_bounds.x,
|
||||
gl_FragCoord.y - dst_bounds.y,
|
||||
dst_bounds.z - gl_FragCoord.x,
|
||||
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() {
|
||||
gl_FragColor = texture2D(texture0, v_texcoord) * alpha;
|
||||
gl_FragColor = texture2D(texture0, v_texcoord) * alpha * compute_coverage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,19 @@ precision mediump float;
|
|||
varying vec2 v_texcoord;
|
||||
uniform sampler2D tex;
|
||||
uniform float alpha;
|
||||
uniform vec4 dst_bounds; // x, y, x+width, y+height in output coordinates
|
||||
|
||||
float compute_coverage() {
|
||||
vec4 d = vec4(
|
||||
gl_FragCoord.x - dst_bounds.x,
|
||||
gl_FragCoord.y - dst_bounds.y,
|
||||
dst_bounds.z - gl_FragCoord.x,
|
||||
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() {
|
||||
gl_FragColor = texture2D(tex, v_texcoord) * alpha;
|
||||
gl_FragColor = texture2D(tex, v_texcoord) * alpha * compute_coverage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,19 @@ precision mediump float;
|
|||
varying vec2 v_texcoord;
|
||||
uniform sampler2D tex;
|
||||
uniform float alpha;
|
||||
uniform vec4 dst_bounds; // x, y, x+width, y+height in output coordinates
|
||||
|
||||
float compute_coverage() {
|
||||
vec4 d = vec4(
|
||||
gl_FragCoord.x - dst_bounds.x,
|
||||
gl_FragCoord.y - dst_bounds.y,
|
||||
dst_bounds.z - gl_FragCoord.x,
|
||||
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() {
|
||||
gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;
|
||||
gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha * compute_coverage();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue