Skip to content

About

Small Vulkan example showcasing dithering to suppress quantization induced banding in rendering

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

vk_dithertoy

Interactive demonstration of dithering techniques for reducing color quantization artifacts in Vulkan.

Overview

Rendering in 8 Bits per color channel may introduce banding artifacts in areas of gradients where small color differences are stretched over a larger area of the screen. 8 Bit quantization doesn't leave enough room for in-between colors to produce a smooth gradient. In this small sample we show how introducing dithering effectively eliminates these banding artifacts. Dithering is a technique whereby noise is introduced into the image to "paper over" the otherwise visible edges between abutting bands of color . This works especially well on nowadays' high resolution monitors, making the artificially introduced dither noise imperceptible.

What this sample does not attempt is to do a deep dive into quantization techniques below 8 bits per channel.

Features and Usage

The sample allows one to select the native swapchain format at program startup.

The displayed color gradient can be changed via the color choser and the 'Delta' sliders underneath. This choses a main color and a second one at a certain distance from the main one. The gradient can be animated, potentially revealing the dither pattern under motion.

Featured dithering patterns:

  • Random noise
  • Bayer matrix 4×4
  • Bayer matrix 8×8
  • IGN (Interleaved Gradient Noise)

Experiments:

  • Dithering in luminance channel (XYZ color space):

    The idea being, does it make a difference when performing the dithering equally to the RGB channels or instead, apply it probably only to the pixels' luminance?

  • sRGB encoding control (before/after dithering):

    Does it make a difference to perform the dithering in sRGB or linear space? Dithering in sRGB space can create a small, but imperceptible amount of bias.

  • Adjustable dither strength:

    Typically the dither strength is set to 1.0 / quantization_steps, where quantizatio_steps depends on the bits per channel of the swapchain.

    It can be increased to make the dither pattern more visible. There are cases, too, where the dither strength adjustment can reveal deficiencies in the machine's display pipeline. For instance, on some GPU's 10bits-per-channel swapchain formats are exposed. vk_dithertoy will choose 1.0/1024.0 as default dither strength in this case. Yet, banding may still be visible. What happens is that the presented image will apparently undergo further quantization down the display pipeline. Adjusting the dither strength to the actual display depth can help (i.e. x4 when displaying 10 bit images on a 8bit monitor)

Keyboard Controls

  • D key - Cycle through dither methods

Further Reading

For an in-depth technical exploration of dithering in games, including color space considerations, blending issues, and optimal noise distributions:

  • Banding in Games: A Noisy Rant by Mikkel Gjøl (Playdead)
    • Covers gamma correction, sRGB rendering, and why dithering must happen in the correct color space
    • Discusses triangular vs uniform noise distributions and their visual impact
    • Addresses practical issues with alpha blending, post-processing, and multi-pass rendering

About

Small Vulkan example showcasing dithering to suppress quantization induced banding in rendering

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages