Skip to content

DitherMode

Narta Xaymar Dirks edited this page Oct 31, 2026 · 2 revisions

DitherMode

DitherMode:Void mode:Int32, level:Int32=1
Parameter Mode Type Default Description
mode In Int32 required 0 for Interleaved Gradient Noise, 1 for a Bayer matrix.
level In Int32 1 The detail of the Bayer matrix, from 1 to 8; it is 1 if left out. A level outside of that is moved to the nearest one, with a warning on the console. It does nothing for mode 0.

Description

Chooses the pattern that Dither hides banding with. It is a BlitzLLVM extension, and it applies to everything that Dither dithers: the picture in the window, 3D drawing and, with Dither 2, what blending makes.

Mode 0 is the default, temporal Interleaved Gradient Noise: a pseudo random pattern that looks like fine grain, and which ignores the level. Mode 1 is a Bayer matrix: an ordered pattern that repeats every 2^level pixels in both directions, and that looks like a regular fine mesh. Gradients dithered with it show less grain than with noise, and the pattern is exactly the same for every pixel with the same color, which compresses well and is what many games use for a retro look. The level is the detail of the matrix: every level doubles its width and height, so level 1 has 4 thresholds in 2x2 pixels, level 2 has 16 in 4x4, level 3 has 64 in 8x8, and so on up to level 8 with 65536 thresholds in 256x256 pixels. A color that 8 bits can show exactly stays as it is. Beyond level 4 (256 thresholds) the thresholds are finer than a step of 8 bits, so higher levels only differ in how the pattern is laid out and in how fast it moves.

Both patterns move from frame to frame, which makes them average out over time as well. The Bayer matrix moves diagonally by one pixel per frame, and its thresholds are rotated by one rank (the next threshold in the order of the matrix, wrapping around), so that every picture still has each threshold as often as the matrix does and every pixel goes through all of them over 4^level pictures; with DitherTemporal off it stays still. The pattern is made on the GPU as part of the shader that dithers, and costs a few operations more than noise. The mode and the level take effect with the next picture, and are kept when Dither is switched off and on again.

Related Commands

Dither, DitherTemporal, HWDither, TransparencyDistanceSortMode

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally