Applying anti-aliasing

You can enable anti-aliasing for an entire Kanzi application, or reduce aliasing in selected nodes by applying multisampling or supersampling.

If most of the content in your application requires anti-aliasing, apply anti-aliasing to the entire application. See Applying anti-aliasing for an entire application.

If only parts of your application require anti-aliasing, use sampling only on those parts that need it:

Applying anti-aliasing for an entire application

When you apply anti-aliasing for the entire application you set the number of anti-aliasing surface samples you want to use. Because this value depends on the device on which you want to run your Kanzi application, check the documentation of that device for supported values. If you set the Samples property to a value which your device does not support, Kanzi Engine clamps the value to the largest value supported by the device driver.

To apply anti-aliasing to the entire application:

or

See Application configuration reference.

Using multisampling

Use multisampling (MSAA) to reduce anti-aliasing in selected parts of your Kanzi application. For multisampling to work, the hardware on which you want to run your Kanzi application must meet any of these requirements:

When you use multisampling, Kanzi does not always store the full resolution of the image to the memory. This means that multisampling requires as little as one quarter of the memory bandwidth as supersampling does.

In the first image no anti-aliasing is applied. In the second image multisampling with 8 samples is applied.

To use multisampling:

  1. In the Library press Alt and right-click Materials and Textures, and select Render Target Texture. See Using render target textures.
    This is the texture to which you render the contents of the node for which you want to reduce aliasing.
  2. In the Library select the Render Target Texture you just created and in the Properties set:
    • Height and Width of the render target texture to the same values you use for the node for which you want to reduce aliasing.
    • Support Simple RenderTarget to disabled.
    • Samples to the number of anti-aliasing samples you want to use.
      For example, set Samples to 4.
      Because this value depends on the device on which you want to run your Kanzi application, check the documentation of that device for supported values. If you set the Samples property to a value which your device does not support, Kanzi Engine clamps the value to the largest value supported by the device driver.
    • Minification Filter to Nearest
    • Magnification Filter to Nearest
    • Mipmap Mode to Base
    • Format to RGBA 8-bit
    See Filtering textures.
  3. In the Library press Alt and right-click Rendering, select Legacy Render Pass (deprecated), and in the Properties set:
    • Render Target Color0 to the Render Target Texture you created in the first step
    • Color Clear Enabled to enabled
    • Resolve After to enabled
    You can also create a Group Render Pass with one or more Legacy Render Pass (deprecated) resources. When you use more than one Legacy Render Pass (deprecated) you have to enable the Resolve After property only for the last Legacy Render Pass (deprecated).
  4. In the Project select the Scene node to which you want to apply multisampling, and in the Properties set the Render Pass property to the Group Render Pass or Legacy Render Pass (deprecated) you use to render the Render Target Texture you created in the first step.
  5. Apply the Render Target Texture you created in the first step to a node where you want to show the multisampled image of the Scene you selected in the previous step. For example:
    1. In the Project press Alt and right-click and select Empty Node 2D.
    2. In the Project select the Empty Node 2D node, in the Properties add the Background Brush property, and in the dropdown menu select + Texture Brush.
    3. Next to the Background Brush property click and set the Brush Texture property of the Texture Brush to the Render Target Texture you want to show in the Empty Node 2D you created in the first step.
    4. In the Project select the Empty Node 2D, and in the Properties add and set the Layout Width and Layout Height properties to the size in which you want to show the content of the Render Target Texture.
    or
    1. In the Project press Alt and right-click and select Image.
    2. In the Project select the Image node, and in the Properties set the Image property to the Render Target Texture you want to show in the Image node.

Using supersampling

Use supersampling (SSAA) to reduce anti-aliasing in selected parts of your Kanzi application if your hardware does not support multisampling. Supersampling requires more resources than multisampling. For example, when you use supersampling Kanzi needs to read and write the whole image to memory.

To use supersampling:

  1. In the Library press Alt and right-click Materials and Textures, and select Render Target Texture. See Using render target textures.
    This is the texture to which you render the contents of the node for which you want to reduce aliasing.
  2. In the Library select the Render Target Texture you just created and in the Properties set:
    • Height and Width of the render target texture to double the size of the final size of the content for which you want to reduce aliasing.
      When you use a large texture which you scale down, you smooth the rough edges that cause aliasing.
    • Minification Filter to Linear
    • Mipmap Mode to Base
    • Format to RGBA 8-bit
  3. In the Project select the node to which you want to apply supersampling, and in the Properties add and set:
    • Off-Screen Rendering and enable the property.
    • Render Target to the render target texture you created in the first step.
  4. Apply the Render Target Texture you created in the first step to a node where you want to show the supersampled image of the node you selected in the previous step. For example:
    1. In the Project press Alt and right-click and select Empty Node 2D.
    2. In the Project select the Empty Node 2D node, in the Properties add the Background Brush property, and in the dropdown menu select + Texture Brush.
    3. Next to the Background Brush property click and set the Brush Texture property of the Texture Brush to the Render Target Texture you want to show in the Empty Node 2D you created in the first step.
    4. In the Project select the Empty Node 2D, and in the Properties add and set the Layout Width and Layout Height properties to the size in which you want to show the content of the Render Target Texture.
    or
    1. In the Project press Alt and right-click and select Image.
    2. In the Project select the Image node, and in the Properties set the Image property to the Render Target Texture you want to show in the Image node.

See also

Application configuration reference

Using render target textures

Rendering best practices