Haio 0.2.X
Homebrew Asset IO/CDN
Loading...
Searching...
No Matches
Haio::Util::Dither Namespace Reference

Functions

constexpr int bayer (int side, int x, int y)
constexpr int bayerSideFor (int levels)

Detailed Description

what the gpu containers need to agree on. these always spoke about colour rather than about files; the old single enum just made it look otherwise. ordered dithering, which is a threshold that depends on where a pixel is rather than on what its neighbours became.

it lives here and not in the palette code because the matrix is not about colour at all: the same thresholds order a gradient, pick which pixels of a mask survive a downscale, or break up a banded sky. a caller that needs one of those should not have to reach into a quantiser to find it.

Function Documentation

◆ bayer()

int Haio::Util::Dither::bayer ( int side,
int x,
int y )
constexpr

the threshold at x,y of a side by side matrix, from 0 to side*side-1.

the matrix is defined by doubling: each step turns one cell into four, keeping the order top left, bottom right, top right, bottom left. that is why the side has to be a power of two, and why the same function answers for a four colour palette and a two hundred and fifty six colour one.

Definition at line 71 of file haio_util.hpp.

Here is the call graph for this function:

◆ bayerSideFor()

int Haio::Util::Dither::bayerSideFor ( int levels)
constexpr

how wide a matrix has to be to hold that many levels, rounded up to a power of two

Definition at line 84 of file haio_util.hpp.

Here is the call graph for this function: