Yotsuba Games
Back to Node List

Palette Swap

palette_swap

Remaps image colors from one palette to another

Reviewed
Guide available
The node name and summary are available in English. Port, parameter, and article details are currently shown in Japanese.

Input Ports

NameTypeDescription
็”ปๅƒ
input
Image
Required
่‰ฒใ‚’ๅค‰ใˆใŸใ„็”ปๅƒใงใ™
ๅ…ƒใƒ‘ใƒฌใƒƒใƒˆ
source_palette
Palette
Required
ไปŠใฎ็”ปๅƒใงไฝฟใ‚ใ‚Œใฆใ„ใ‚‹่‰ฒใฎไธฆใณใงใ™
ๅทฎใ—ๆ›ฟใˆๅ…ˆใƒ‘ใƒฌใƒƒใƒˆ
target_palette
Palette
Required
ๅทฎใ—ๆ›ฟใˆใŸใ„่‰ฒใฎไธฆใณใงใ™

Output Ports

NameTypeDescription
็”ปๅƒ
output
Image
่‰ฒ็ฝฎๆ›ๅพŒใฎ็”ปๅƒ

Parameters

NameTypeDefaultRangeDescription / Options
่‰ฒใฎๆŽขใ—ๆ–น
mode
Enum
Exactโ€”

ใฉใฎ่‰ฒใ‚’็ฝฎใๆ›ใˆใ‚‹ใ‹ใฎๆŽขใ—ๆ–นใงใ™

  • ๅฎŒๅ…จไธ€่‡ดExact
    ๅ…ƒใƒ‘ใƒฌใƒƒใƒˆใจๅฎŒๅ…จใซๅŒใ˜่‰ฒใ ใ‘ใ‚’ๅทฎใ—ๆ›ฟใˆใพใ™
  • ๆœ€่ฟ‘ๅ‚Nearest
    ๅ…ƒใƒ‘ใƒฌใƒƒใƒˆใฎไธญใ‹ใ‚‰ไธ€็•ช่ฟ‘ใ„่‰ฒใ‚’ๆŽขใ—ใฆๅทฎใ—ๆ›ฟใˆใพใ™
ๅ…ƒใฎ้€ๆ˜Žๅบฆใ‚’ไฟใค
preserve_alpha
Bool
trueโ€”

่‰ฒใ‚’ๅค‰ใˆใฆใ‚‚ใ€ๅ…ƒ็”ปๅƒใฎ้€ๆ˜Žๅบฆใฏใใฎใพใพๆฎ‹ใ—ใพใ™

What is it for?

  • Change the color scheme without changing the shading
  • Batch-produce color variants for characters or weapons
  • Recolor existing images to match a theme color

Overview

Recolors an image using the rule "color N in the source palette โ†’ color N in the replacement palette." This is the primary node for batch-producing color variants. Because shading structure remains completely intact, a prepared palette is enough to create enemy variants or material changes such as iron โ†’ gold.

Usage tips

  • The standard setup: collect the source palette with palette_extract(Exact) โ†’ build a new scheme in the same order with palette_create โ†’ replace it here. Everything depends on matching the order of both palettes.
  • For batch production, prepare several replacement palettes and send them through batch_render, or mechanically generate hue variants from the source palette with palette_adjust_hsv.
  • For already-quantized pixel art, Exact is the only necessary choice: strict and safe. Use Nearest only for assets whose anti-aliasing or transparency shifts colors slightly.

Common pitfalls

  • Some colors do not change: in Exact, colors do not match exactly; a difference of one value still fails. Align the image to the source palette first with palette_quantize, or use Nearest.
  • Mappings shift and break the scheme: both palettes map from their first entry in order. If lengths differ, only the shorter length is used. Match order and length.
  • Only one color needs changing: color_select_replace is simpler when a palette is unnecessary.

Finding colors

  • Exact
    • Replaces only colors that exactly match the source palette.
    • Best for strict pixel-art recoloring.
  • Nearest
    • Finds and replaces with the nearest source-palette color.
    • Useful when slightly shifted colors should map to nearby entries.

Notes

  • Source and replacement palettes map in order from their first entries.
  • If one is longer, only entries up to the shorter length are used.
  • In Exact, unmatched colors remain unchanged.

Examples

  1. Replace a red character scheme with a blue one.
  2. Build a source palette with Palette Extract and convert to another theme palette.
  3. Replace only a weapon's metal colors with another metal set.
  4. Recolor a translucent asset while preserving opacity with preserve_alpha = true.

Related nodes

  • palette_extract โ€” collect the source palette, the go-to upstream step
  • palette_adjust_hsv / palette_adjust_oklch โ€” generate replacement palettes mechanically
  • color_select_replace โ€” replace only one or two colors
  • common_palette_ref + indexed color โ€” index-based color management across a project
Back to Node List
Palette Swap โ€” PixPipeline Node Reference