Black CraftDev

Docs/Textures

Palette

Named swatches as hex codes: import and export .hex, .gpl and .ase, extract from a texture or materials, reduce a texture to a palette, and pick swatches in other tools.

EditionPro only · launching soonMenuTools›BlackCraft›Hexbench›Textures›PaletteClassPaletteWindow

A palette is an asset holding named swatches, which you edit as hex codes. The Palette window is for browsing and editing them. Palette Swap recolours a texture from one palette to another.

Open it with Tools›BlackCraft›Hexbench›Textures›Palette, or double-click a palette asset. New creates one, and so does Create > BlackCraft > Palette.

Palettes

Every palette in the project is listed in the sidebar with a strip of its colours, and the toolbar search filters the list. You can also drop a palette asset on the window to open it.

To rename a palette, click its name at the top and type, double-click it in the sidebar, or press F2. Enter confirms and Escape cancels. Right-clicking a palette in the sidebar, or using the header's three-dot menu, gives Rename, Duplicate, Show in Project and Delete. Delete moves the asset to the trash. The header's Sort, Use and Export apply to the open palette.

Swatches

Clicking a swatch selects it and copies its hex code, ready to paste into a colour picker's hex box or onto a colour field with Ctrl+V. Drag swatches to reorder them. The right-click menu has Copy Hex, Apply To, Duplicate and Delete, and + adds a copy of the selected swatch.

When the swatch area has focus, the arrow keys move the selection, Delete removes the swatch, Ctrl+C copies its hex, Ctrl+D duplicates it, and Ctrl+V adds a new swatch from a hex code on the clipboard.

The Swatch section edits the name, the hex code and the colour, and shows the RGB and HSV values. Hex can be RRGGBB, RRGGBBAA or short RGB, with or without the #.

Sort orders the palette from dark to light, or around the hue wheel with greys first. All edits are ordinary undo steps.

Apply To

Apply To, found in the Swatch section and on a swatch's right-click menu, sends the selected swatch somewhere.

Selected Materials sets it on a colour property of the materials selected in the Project window, or the materials used by the selected renderers. Where only some of them have a property, the menu says how many. Built-in and package materials are read-only, so they are skipped.

Ramp Maker > Add Stop adds the colour to the Ramp Maker's gradient in its widest gap. Unity gradients hold eight colour keys at most.

To send the whole palette, use Use > Ramp Maker. Banded gives each colour an equal hard band and Smooth blends between them. A longer palette gives up eight colours, picked evenly from first to last.

Texture Editor > Colour Overlay Layer adds a Colour Overlay in the swatch's colour to the texture open in the Texture Editor.

Files

Import... reads a file into a new palette asset in the folder selected in the Project window. Export writes the open palette out.

FormatRead byKeeps
.hexLospec, most pixel art toolsColours only: no names, no alpha
.gplGIMP, Krita, Inkscape, AsepriteColours, names, the palette's name
.asePhotoshop, Illustrator, most colour sitesColours, names, the palette's name

The .ase here is Adobe Swatch Exchange, which shares its extension with Aseprite files. CMYK, Lab and grey swatches in it are converted to sRGB on import.

Extract a Palette

The Extract a Palette section builds a palette from existing art and shows the colours it found before saving anything.

  1. Set From to a Texture (pick one, or drop it anywhere on the window) or to Selected Materials, which takes the materials selected in the Project window plus those on selected renderers.
  2. Set Colours and Method. The strip updates as you go.
  3. Create Palette saves a new palette next to the source. To use the open palette, Replace Swatches swaps its colours for the found ones and Add to Palette appends any it does not already have. Both can be undone.

With materials as the source, every colour property that differs from the shader's default is taken, along with Colours per Map main colours from each base map, tinted by the base colour.

On a texture or on materials, Send To > Extract Palette does the whole thing in one step with the current settings.

There are two methods, and both give the same result every time they run. Median Cut splits the colours into boxes and holds on to small accents. K-Means refines those boxes in Oklab, a colour space where equal distances look equally different, so the colours land where the eye would group them.

If a picture has no more colours than you asked for, they come back exactly, which keeps a pixel art palette intact. Alpha Cutoff ignores transparent pixels so a sprite's empty background is not counted as a colour.

In the Texture Editor

Reduce to Palette, under Palette in the Texture Editor's Add menu, snaps every pixel to the nearest colour of a palette, inside a stack where it can be changed at any time. It turns a painted texture into pixel art colours, or holds a set of textures to one palette. Make Palette takes that many colours from the picture into a new palette and uses it. With Dither set to Ordered, a 4x4 pattern is laid between neighbouring colours so gradients survive a small palette, and Strength scales it. In the Palette window header, Use > Texture Editor > Reduce to Palette adds this layer for the open palette.

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.

Swatches in other tools

Colour and gradient fields in these tools carry a small palette button:

On a colour field it opens the project's palettes. Click a swatch to use it, or + to add the field's colour to the palette shown. On a gradient field it lists every palette as a strip, and clicking one builds the gradient from it, Banded or blended. A gradient holds eight colours, so a longer palette gives up eight, picked evenly from first to last.

For programmers

A static method marked [ColorTarget("Menu/Label")] that takes (Color color, string name) shows up under Apply To. The optional Validate argument names a parameterless static bool method that greys the item out.

To give a colour or gradient field of your own the palette button, call ColorSwatches.Attach(field) after building it. The button stays hidden when the Palette tool is not installed.

palettecolourcolorswatchhexgplaselospecextractk-meansmedian cutpixel artreduceditherindexed