NoesisGUI

UI Antialiasing

NoesisGUI offers two ways to prevent aliasing and give a smoother appearance to user interfaces. Aliasing is an effect where lines appear jagged or have a "staircase" appearance. This can happen if the graphics output device does not have a high enough resolution to display a straight line.

Antialiasing reduces the prominence of these jagged lines by surrounding them with intermediate shades of color. Although this reduces the jagged appearance of the lines, it also makes them blurrier.

AntialiasingTutorial1.png

The algorithms supported by NoesisGUI are:

  • GPU Multisample Antialiasing (MSAA)
  • Per Primitive Antialiasing (PPAA)

Multisample Antialiasing

MSAA is the default mode and it is implemented by the GPU. Most modern GPUs are capable of this form of antialiasing. In multisample antialiasing, each pixel at the edge of a polygon is sampled multiple times. For each sample-pass, a slight offset is applied to all screen coordinates. This offset is smaller than the actual size of the pixels. By averaging all these samples, the result is a smoother transition of the colors at the edges.

Noesis Views always display content in the active render target. Just binding a render target with MSAA enabled will render the UI with antialiasing enabled. Our Application Framework supports enabling MSAA by using the command line switch '--samples N'.

In case you also want MSAA in the offscreens, you need to indicate the number of samples before initializing each View in the render thread.

Ptr<GLRenderDevice> device = *new GLRenderDevice();
device->SetOffscreenSampleCount(8);

view->GetRenderer()->Init(device);

Note

We only recommend enabling MSAA for offscreen in high-end devices. With MSAA, render targets need to be uncompressed and resolved. These are expensive operations that need to be done per frame.

Pros

  • MSAA offers better quality in comparison with PPAA.
  • Alpha Blending is not necessary.

Cons

  • In terms of performance MSAA requires a lot of memory bandwidth and hardware.
  • Not very friendly if your app is not using MSAA.

Per-Primitive Antialiasing

For cases where MSAA cannot be used or it is expensive, Noesis provides a cheap solution that extrudes the contours of the geometry and smooths them using alpha blending.

PPAA can be enabled in a view by activating the flag 'RenderFlags_PPAA'.

view->SetFlags(Noesis::RenderFlags_PPAA);

Note

This is the default mode used by our Application Framework

This will enable PPAA globally for the view. PPAA can also be selectively disabled per node by using the extended XAML property PPAAMode. PPAA generates extra geometry so in cases where PPAA is not needed, for example when using a rectangle that is never rotated, it is a good idea to disable PPAA to save bandwidth.

There is also two extended XAML properties to control how the extrusion happens, PPAAIn and PPAAOut. The first one indicates how many pixels the geometry is shrunk and the second one indicates how many pixels vertices are extruded out. Between the PPAAIn and PPAAOut area, alpha transitions from 1.0 to 0.0. The default values are quite conservative to avoid glitches but depending on the geometry they can be increased to improve the antialiasing result.

PPAAMode, PPAAIn and PPAAOut are inherited properties that are propagated down the tree.

Note

Mathematically correct values are 'PPAAIn=0.5' and 'PPAAOut=0.5'. Noesis is using by default 'PPAAIn=0.25' and 'PPAAOut=0.5' to avoid glitches that can appear when shrinking the geometry.

AntialiasingTutorial2.png
<Canvas
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
  Background="White">

  <StackPanel Orientation="Horizontal">
    <Rectangle noesis:Element.PPAAMode="Disabled" Fill="Black" Width="100" Height="100">
      <Rectangle.RenderTransform>
        <TransformGroup>
          <RotateTransform Angle="60"/>
          <TranslateTransform X="100" Y="10"/>
        </TransformGroup>
      </Rectangle.RenderTransform>
    </Rectangle>
    <Rectangle noesis:Element.PPAAMode="Default" Fill="Black" Width="100" Height="100">
      <Rectangle.RenderTransform>
        <TransformGroup>
          <RotateTransform Angle="60"/>
          <TranslateTransform X="150" Y="10"/>
        </TransformGroup>
      </Rectangle.RenderTransform>
    </Rectangle>
    <Rectangle noesis:Element.PPAAIn="1" noesis:Element.PPAAOut="1" Fill="Black" Width="100" Height="100">
      <Rectangle.RenderTransform>
        <TransformGroup>
          <RotateTransform Angle="60"/>
          <TranslateTransform X="200" Y="10"/>
        </TransformGroup>
      </Rectangle.RenderTransform>
    </Rectangle>
  </StackPanel>
</Canvas>

Pros

  • Performance is equivalent to 2x MSAA or less
  • Quality is in the range of 4x - 8x MSAA
  • Can be tweaked per element tree getting much more quality

Cons

  • Geometries are slightly altered. UI needs to be designed with PPAA in mind
  • Needs Alpha Blending. This may be a problem in tiled based architectures
  • Needs a lot of extra thin triangles
  • Poor quality when using 3D UI. We recommend using MSAA in this case.
© 2017 Noesis Technologies