Multi-
Sample
Anti-
Aliasing (MSAA) that both ObjReader and Objector are currently using to anti-alias their renders has two restrictions:
- it affects geometric edges only but not the borders between differently colored portions of textured planes nor the visible edges of alpha-textured objects; and
- it is ineffective entirely if OpenGL uses any other render target than the on-screen window.
Deficiency #1 above can be partially compensated for by heavy anisotropic correction of textures, and that's what we are using now too. But 16/32x MSAA and 16x aniso combined are a very, very heavy burden for our rendering pipelines indeed.
Furthermore, since we will have to use
Frame
Buffer
Objects (FBOs, in fact GPU memory texture pixel array buffers) to be able to apply post-processing effects like in my earlier post at least in our Programmable Pipeline (PPL), we need to find an alternative to MSAA.
Fast Appro
Ximate
Anti-
Aliasing (FXAA) is an algorithm that resolves deficiencies #2 and #1 (in its plain- and alpha-textured aspects) entirely, and is at the same time equivalent to approx. 4x MSAA in what regards geometric edges. It is also very lightweight and bogglingly fast: it adds no more than 1% GPU cost to medium-sized window renders, and no more than 2%, in full screen.
Mathematically, FXAA is a very tight, subpixel-perfect, luma-corrected, rhombus-shaped kernel blur filter applied to exery pixel in the final FBO that would texturize the viewport-sized quad to be rendered into the on-screen window.
Being essentially a blur filter, FXAA does add some insignificant "soapiness" to the overall look of the scene. It is also known to yield artifacts in places where the scene may contain some distant objects textured as posters or signboards displaying text. Yet I hear that both drawbacks can be efficiently eliminated by applying yet another Sobel edge detection/sharpening filter to FXAA corrected pixels. It will remove both "soapiness" and text texturing artifacts I mentioned. I do have some fast solutions of such image sharpen filter shaders for use in streaming video rendering, but they are written in DirectX HLSL rather than GLSL, so this will have to wait till I translate them for use with this FXAA shader.
FXAA capability is included with nVidia drivers' Control Center as a 3D rendering option but i) it is a system-wide setting, ii) it can't be enabled programmaticaly for a specific OpenGL application through the Control Center API, and iii) it's a nVidia-only solution.
In the meantime, consider my test case application appended below. Left-click and drag the white splitter bar across the viewport to see how FXAA anti-aliases the jaggy picture that emulates our future post-processing FBO. It performs so well that, even when the window is sent full screen and the jaggies get exaggerated to nearly twice the size they can ever get in reality, the effect is still stunning. The app renders continuously at approx. 30FPS just to show off how low the FXAA cost really is.
