Skip to content

palettizeNearest

palettizeNearest(inputColor, paletteTex, paletteSize): Node<"vec4">

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

Find nearest color in palette by comparing RGB distance. More accurate than luminance-based but more expensive.

Parameters

inputColor

Node<"vec4">

The input color (vec4 with alpha)

paletteTex

Texture

Palette texture (horizontal strip)

paletteSize

number

Number of colors in palette (max 16)

Returns

Node<"vec4">

Color snapped to nearest palette color

Example

// Find nearest color in 8-color palette
palettizeNearest(color, palette8, 8)