Skip to content

palettizeDithered

palettizeDithered(inputColor, paletteTex, paletteSize, dither, screenCoord?): Node<"vec4">

Defined in: packages/nodes/src/retro/palettize.ts:106

Map colors to palette with dithering for smoother transitions. Uses Bayer matrix dithering to blend between palette colors.

Parameters

inputColor

Node<"vec4">

The input color (vec4 with alpha)

paletteTex

Texture

Palette texture (horizontal strip)

paletteSize

FloatInput

Number of colors in palette

dither

FloatInput = 0.5

Dither strength between palette colors (0-1, default: 0.5)

screenCoord?

Node<"vec2">

Screen coordinates for dithering pattern

Returns

Node<"vec4">

Color snapped to palette with dithering

Examples

// GameBoy 4-color palette with dithering
palettizeDithered(color, gbPalette, 4, 0.5, uv().mul(textureSize))
// C64 palette with strong dithering
palettizeDithered(color, c64Palette, 16, 0.8, screenCoord)