Hi everyone, I am developing a whitboard android APP based on skia targeting to a very large meeting screen like ZOOM DTEN D7
. The big screen's resolution is 3840x2160, and supports up to 4xMSAA.Polygons rendered are very jaggy, although I enabled 4xMSAA (tools/sk_app/android/GLWindowContext_android.cpp). I also tried raster render backend (tools/sk_app/android/RasterWindowContext_android.cpp), but did not works well too.
I try to draw ploygons to a 7680x4320 offscreen surface and then downscale to the screen, just like what the example tools/viewer/ThinAASlide.cpp dose. This mitigates a little, but there are still obvious sawteeth especially sloping lines.
I found the mapbox anroid demo has very nice polygons. If you don't look very closely, you can't see the jagged edges at all. I think the blur in the fragment shader is the real solution.
So any suggestion how to improve skia anti-aliasing effect on the big screen?
below is the fragment shader of mapbox-gl-js\src\shaders\line.fragment.glsl
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * v_width2.s;
// Calculate the antialiasing fade factor. This is either when fading in
// the line in case of an offset line (v_width2.t) or when fading out
// (v_width2.s)
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
gl_FragColor = color * (alpha * opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}