Black CraftDev

Docs/Textures

Palette Swap

Recolour textures by mapping each colour to a new one from a palette, and save the results as copies: team colours, seasons, sprite and pixel art variants.

EditionPro only · launching soonMenuTools›BlackCraft›Hexbench›Textures›Palette SwapClassPaletteSwapWindow

Palette Swap recolours textures by mapping each of their colours to a new one, and saves the results as copies. It is meant for sprite and pixel art variants: team colours, seasons, a poisoned version of an enemy.

Open it with Tools›BlackCraft›Hexbench›Textures›Palette Swap, with Send To > Palette Swap on one or more textures, or from Use > Palette Swap in the Palette window header.

The preview fills the left of the window and the settings sit on the right, top to bottom in the order you use them.

  1. Drop the textures on the window. Sheets that share colours, such as a body and its weapon, can go in together and are saved together. Click a texture in the list to preview it.
  2. Under Source, leave From on Picture to take the textures' own colours, up to Colours of them. Pixel art usually has fewer, and then every colour comes back exactly. Set it to Palette to look for the colours of a palette asset instead.
  3. Pick a Target palette if the new colours already exist as one. Rows are paired with its swatches by lightness. A target is optional.
  4. Work down the Mapping rows. Each shows a source colour, what it becomes, and how much of the picture it covers.
  5. Check the preview, then Save Copy, or Save Copies with several textures.

Rows

To change a row, click its target. The drop-down lists the target palette's swatches, and the menu at its top switches to any other palette; a swatch from another palette is stored as a custom colour. Custom opens a colour picker that updates the preview as you drag, and Leave keeps the colour as it is.

A quicker way uses the target palette's swatches, shown under its field: select a row and click a swatch. The next row is selected after, so a whole palette can be mapped in a run of clicks. When the list has focus, the arrow keys move between rows, Enter opens the picker and Delete sets Leave. The right-click menu adds Same as Source, Auto Map This Row and copying either hex code.

Hovering or selecting a row dims every pixel that colour does not claim; Highlight in the toolbar turns this off. In the other direction, clicking a pixel in the preview selects the row that claims it, and the line under the preview names the colour under the pointer and what it turns into. View switches between the Original, the Swapped result and both Side by Side, which pan and zoom together. By Share sorts the rows with the most-used colours first and Hide Unused drops colours this texture does not use.

Matching

Auto Map re-pairs every row by lightness, by order or by nearest colour, or sets them all to Leave. Reverse exchanges a source palette and a target palette, to turn a variant back.

Tolerance sets how far a pixel can be from a source colour and still count as a match. Use 0 for pixel art. Around 2 is the smallest step you can see, and 5 to 15 catches compression artefacts and soft edges. Each pixel takes the nearest source colour within reach, and pixels with none in reach are left alone. A row set to Leave keeps its colour unchanged and also stops a neighbouring source colour from taking its pixels.

Mode decides how the new colour is applied. Replace paints the target colour flat. Keep Shading shifts each pixel by the same amount its source colour shifts, which preserves anti-aliasing and painted shading.

Saving

The three-dot menu turns the session into assets. Save Source as Palette writes the picture's colours to a palette and makes it the source. Save Result as Palette writes what every row becomes, custom colours included, as a new palette and maps onto it one to one, so a variant made by hand can be reused on other sheets.

Each copy gets its texture's import settings, sprite slicing included, so a variant sprite sheet can sit right beside the original. Copies go beside their textures unless Folder names another, and take the Suffix on their names, which defaults to the target palette's name. Save as PNG or TGA, because JPG blurs colours off the palette. The footer's Send To passes the results on, and Texture Editor opens the previewed texture there with this swap as a layer.

PNG and JPG are read straight from the file, so a compressed or downsized import does not shift any colours. Other formats are read from the import; the status line mentions it, and a little Tolerance absorbs the drift. The preview works on a copy no bigger than 1024 pixels a side, and saving always works at full size. Alpha is left as it was.

Swatches and mappings are keyed by stable ids, so reordering a palette does not break a mapping. Colours taken from a picture are keyed by their hex code, so taking them again keeps every row whose colour is still there.

In the Texture Editor

Palette Swap, under Palette in the Texture Editor's Add menu, is this window as a layer, with the same source, target, rows and matching, inside a stack where it can be changed at any time. Its Take button reads the colours of the picture the stack starts from, before any layer runs. The layer matches on 8-bit colour codes, so pixel art colours match exactly in a Linear project too. It reads at most 256 colours.

palette swaprecolourrecolorpaletteswatchpixel artspritevarianttoleranceshading