Applying anti-aliasing

You can apply anti-aliasing to an entire Kanzi application, or only to selected nodes:

By default, the Kanzi Studio Preview and the Kanzi Application Player on Windows apply anti-aliasing using four samples. For both you can configure the amount of anti-aliasing that you want to use. See Setting anti-aliasing in the Preview and Application Player.

Applying anti-aliasing to 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 number of anti-aliasing surface samples 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 Surface properties.

Setting anti-aliasing in the Preview and Application Player

By default, the Kanzi Studio Preview and the Kanzi Application Player on Windows apply anti-aliasing using four samples. For both you can configure the amount of anti-aliasing that you want to use.

If you have a Kanzi application with a C++ application, to see your content in the Kanzi Studio Preview and Kanzi Application Player the same way as when running your Kanzi application on a target device, you can set anti-aliasing in an application.cfg file. See Applying anti-aliasing to an entire application.

To set anti-aliasing in the Kanzi Studio Preview for a Kanzi application without a C++ application:

  1. In the Kanzi Studio main menu select Project > Properties and in the Properties in the Preview section set the value of the Preview Working Directory property to the directory where you want to store the application.cfg to configure the Preview.
    For example, set the Preview Working Directory property to Application Player. This way you can apply the same anti-aliasing setting to the Preview and the Kanzi Application Player on Windows. If the <ProjectName>/Application Player directory does not yet exist, select File > Export > Export as KZB Player for Windows. See Building and deploying Kanzi applications to Windows from Kanzi Studio.
  2. In the directory that you set in the previous step, create or open the application.cfg file, and add and set the SurfaceSamplesAntialiasing parameter to the number of anti-aliasing samples that you want the Preview to use.
    For example, to disable anti-aliasing in the Preview, in the application.cfg add:
    SurfaceSamplesAntialiasing = 0
  3. In Kanzi Studio restart the Preview.

Using multisampling

Use multisampling (MSAA) to reduce 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:

Multisampling requires less resources than supersampling. When rasterizing a polygon, multisampling generates extra samples only for the fragments at the edges of the polygon, while supersampling generates extra samples for all fragments in the polygon.

When using tile-based multisampling, usually on mobile platforms, the GPU generates multiple samples only for one GPU tile at a time. The GPU resolves the samples implicitly when writing that tile back to texture memory, saving memory and GPU bandwidth.

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 Rendering, and select Compose and Blit Pass.
    Compose and Blit Pass template contains the render pass structure that enables you to blit to the screen Composition Target Render Pass render passes or textures using a specific material. The template contains these render passes:
  2. In the Project select the Scene node for whose content you want to reduce aliasing and in the Properties set the Render Pass property to the Compose and Blit Pass render pass.
    Kanzi now renders the Scene using the Compose and Blit Pass render pass.

  3. In the Library select Compose and Blit Pass > Composition Target Render Pass, in the Properties add the Multisample Level property, and set it to the number of anti-aliasing samples that you want to use.
    For example, set Multisample Level to 8.
    See the documentation of the device on which you want to run your Kanzi application for supported values, because the number of anti-aliasing samples depends on the device. If you set the Multisample Level property to a value which your device does not support, Kanzi Engine clamps the value to the largest value supported by the device driver.

Kanzi now applies anti-aliasing to the content of the Scene node.

Using supersampling

Use supersampling (SSAA) to reduce aliasing in selected parts of your Kanzi application if your hardware does not support multisampling. Supersampling requires more resources than multisampling. When rasterizing a polygon, supersampling generates extra samples for all fragments in the polygon, while multisampling generates extra samples only for the fragments at the edges of the polygon.

Supersampling a composition target

You can supersample a composition target texture when you render 3D content with a Composition Target Render Pass. To supersample a composition target texture you must use the composition target which the Composition Target Render Pass creates automatically.

To supersample a composition target:

  1. In the Library press Alt and right-click Rendering, and select Compose and Blit Pass.
    Compose and Blit Pass template contains the render pass structure that enables you to blit to the screen Composition Target Render Pass render passes or textures using a specific material. The template contains these render passes:
  2. In the Project select the Scene node whose content you want to supersample and in the Properties set the Render Pass property to the Compose and Blit Pass render pass.
    Kanzi now renders the Scene using the Compose and Blit Pass render pass.
  3. In the Composition Target Render Pass that you use to render the nodes which you want to supersample, add the Resolution Multiplier property, and set it to the value by which you want to multiply the resolution of the composition target texture.

Supersampling a render target texture

You can supersample a render target texture which you use in a Texture Brush or as an image in an Image node.

To supersample a render target texture:

  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:
  3. In the Project select the node to which you want to apply supersampling, and in the Properties add and set:
  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 content to a composition target

Rendering best practices