layer-pixel-art

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Layer Pixel Art

Layer 像素画

Overview

概述

Pixel art is the generation task most likely to come back subtly wrong: a picture of pixel art, soft-edged and anti-aliased at an arbitrary grid, rather than pixel art. Getting it right is mostly about excluding the defaults.
Layer ships two deterministic sprite-sheet utilities alongside generation.
pack_sprite_sheet
assembles separate frame images into one uniform-cell sheet on a transparent background, and
split_sprite_sheet
cuts a sheet into its cells in reading order. These are named directly rather than discovered because they are first-party tools rather than models, with no competing alternative in the catalogue.
Generation mechanics are in the
layer
skill. If a sibling skill named here is missing from your available skills, ask the user to install it (
npx skills add layerai/skills --skill <name>
); unattended, proceed from tool schemas and flag the gap.
像素画是最容易出现细微错误的生成任务:模型生成的往往是_看起来像_像素画的图片, 边缘柔和、带有抗锯齿,并且处于任意网格上,而不是真正的像素画。要做好这件事, 主要在于明确排除模型的默认行为。
Layer 在图像生成之外还提供两个确定性的 sprite sheet 工具。
pack_sprite_sheet
将独立的帧图像组装成一张单元格尺寸统一、背景透明的 sheet,
split_sprite_sheet
则按照阅读顺序将 sheet 切分为各个单元格。这些工具直接按名称调用,而非动态发现, 因为它们是 Layer 的第一方工具而非模型,并且工具目录中没有其他可选方案。
生成机制位于
layer
skill 中。如果此处提到的同级 skill 未包含在你可用的 skills 中, 请要求用户安装(
npx skills add layerai/skills --skill <name>
);在无人值守的情况下, 则根据工具 schema 继续操作,并指出缺失项。

Name the grid and the palette

每次都用数字明确网格和调色板

Both, every time, as numbers.
  • Grid: "32x32 sprite", "16x16 tile". A model given no grid produces something pixel-ish at no particular resolution, which cannot be cleaned up afterwards.
  • Palette: a count and a family. "Limited 16-colour palette, muted earth tones" constrains the output in a way "retro colours" does not.
  • Era, when the user has one in mind: 8-bit NES-era flat colour, 16-bit SNES-era with shading ramps, or modern high-resolution pixel art. These look nothing alike.
这两项每次都必须明确,并以数字表示。
  • 网格:“32x32 sprite”、“16x16 tile”。如果不给模型指定网格,它生成的图像只会有些像素风格, 却没有明确的分辨率,之后也无法进行清理。
  • 调色板:指定颜色数量和色系。“有限的 16 色调色板、低饱和度大地色系”能够有效约束输出, 而“复古色彩”则不能。
  • 时代风格:如果用户心中已有特定风格,应明确说明:8-bit NES 时代的平涂色彩、 带明暗渐变层次的 16-bit SNES 时代,或现代高分辨率像素画。这些风格彼此截然不同。

Exclude the defaults, in the prompt

在提示词中排除默认行为

The defects are predictable, so name them as exclusions: no anti-aliasing, no blur, no gradients, no soft shadows, hard-edged pixels only, one pixel per cell. Where the model declares
negative_prompt
, put them there instead. Also state the background: "isolated on transparent background" or "flat single-colour background", since a generated backdrop has to be cut out and pixel art does not survive a sloppy cut.
这些缺陷是可以预测的,因此应将它们明确列为排除项:不要抗锯齿、不要模糊、不要渐变、 不要柔和阴影,只使用硬边缘像素,每个单元格只包含一个像素。如果模型支持
negative_prompt
, 则应将它们写入该参数。还要说明背景:“隔离在透明背景上”或“纯色背景”,因为生成的背景 需要经过抠除处理,而粗糙的抠图会破坏像素画。

Sprite sheets and walk cycles

Sprite sheet 与 walk cycle

Do not ask one generation for a sheet of frames. Models produce a grid of loosely related drawings, and the character changes between cells, which is exactly what a sheet must not do.
The working sequence:
  1. Generate and approve one frame: the idle or contact pose, isolated on transparent.
  2. Generate each remaining frame separately, with the approved frame attached as
    reference_image
    , and describe only what changed: "same character, same palette, same 32x32 grid, left leg forward mid-stride, right arm back."
  3. Review the frames as a set and reroll the ones that drifted.
  4. pack_sprite_sheet
    to assemble them into a uniform-cell sheet. Its input schema is the authority on the argument shape, so read it rather than assuming the parameter name.
Every frame after the first references frame one, not the frame before it. Chaining each frame off the last one compounds drift, so by frame four the knight is a different knight.
When a trained pixel style is in play, attach it as
reference_sets
and omit
base_model_id
entirely, so the server picks a model that can apply it. Use the same set, the same weight, and the same reference frame on every frame of the cycle.
A four-frame cycle (contact, down, passing, up) reads as motion and is far more reliable than eight. Start there and add frames only if the motion needs them.
Going the other way,
split_sprite_sheet
cuts a user's existing sheet into individual frames, which is the way to edit one frame of a sheet without touching the others.
不要要求一次生成直接产出包含多帧的 sheet。模型会生成一组彼此仅有关联的图画, 角色在各个单元格中发生变化,而这正是一张 sheet 绝不应该出现的情况。
可行流程如下:
  1. 生成并确认一帧图像:静止姿势或接触姿势,背景透明并与主体分离。
  2. 分别生成其余每一帧,将已确认的帧作为
    reference_image
    附加, 并且只描述发生变化的部分:“同一角色、同一调色板、同一 32x32 网格,左腿向前迈至中途,右臂向后。”
  3. 将所有帧作为一个整体进行审查,并重新生成出现偏移的帧。
  4. 使用
    pack_sprite_sheet
    将它们组装成单元格尺寸统一的 sheet。 其输入 schema 是参数格式的权威依据,因此应读取 schema,而不要自行假定参数名称。
第一帧之后的每一帧都应引用第一帧,而不是前一帧。让每一帧都基于上一帧生成会不断累积偏移, 因此到了第四帧,骑士就会变成另一个骑士。
使用训练好的像素风格时,应将其作为
reference_sets
附加,并完全省略
base_model_id
, 让服务器选择一个能够应用该风格的模型。循环中的每一帧都应使用同一个集合、相同权重和同一参考帧。
四帧循环(contact、down、passing、up)能够呈现出运动效果,而且远比八帧循环可靠。 应先从四帧开始,只有在动作确实需要时再增加帧数。
反过来,
split_sprite_sheet
可以将用户现有的 sheet 切分为独立帧, 这样可以编辑其中一帧,而不会影响其他帧。

Tiles

Tile

A pixel tile that repeats seamlessly is a tiling problem before it is a pixel problem, so filter for the
tileability
capability and read
layer-textures
for how to specify scale and avoid visible repetition. Everything on this page about grid, palette, and hard edges still applies.
能够无缝重复的像素 tile 首先是一个平铺问题,然后才是像素问题。因此,应筛选具备
tileability
能力的模型,并阅读
layer-textures
,了解如何指定比例以及避免出现明显的重复感。 本页关于网格、调色板和硬边缘的所有要求仍然适用。

Worked example

实例

"A 32x32 walk cycle for our knight sprite."
  1. Generate the contact pose.
    list_base_models
    with
    filter.use_case: "text_to_image"
    , take the first result, then prompt: "32x32 pixel art sprite of an armoured knight, side view, contact pose with left foot forward, limited 16-colour palette, 16-bit era shading, hard-edged pixels, no anti-aliasing, no blur, no gradients, isolated on transparent background."
  2. Approve one. This frame is now the reference for everything else.
  3. Three more runs, one per remaining frame, each attaching the approved frame as
    reference_image
    and naming only the pose change.
  4. Check the four together for drift in palette, height, and armour detail. Reroll any that moved.
  5. pack_sprite_sheet
    with the four
    file_id
    values, which returns the sheet on a transparent background.
“为我们的骑士 sprite 制作一个 32x32 walk cycle。”
  1. 生成接触姿势。使用
    list_base_models
    ,设置
    filter.use_case: "text_to_image"
    , 取第一个结果,然后输入提示词:“32x32 像素画 sprite,一名身披铠甲的骑士,侧视图, 左脚向前的接触姿势,有限的 16 色调色板,16-bit 时代风格着色,硬边缘像素, 不要抗锯齿,不要模糊,不要渐变,隔离在透明背景上。”
  2. 确认其中一帧。该帧现在将作为其余所有帧的参考。
  3. 再运行三次,每次生成剩余的一帧,将已确认的帧作为
    reference_image
    附加, 并且只说明姿势的变化。
  4. 将四帧放在一起检查调色板、身高和铠甲细节是否发生偏移。重新生成任何出现变化的帧。
  5. 使用四个
    file_id
    值调用
    pack_sprite_sheet
    ,返回透明背景上的 sheet。

Common mistakes

常见错误

  • Omitting the grid size, then trying to downsample a soft image into pixels.
  • Asking one generation for a whole sprite sheet.
  • Forgetting the anti-aliasing and blur exclusions, which are the defaults being excluded.
  • Generating frames independently with no reference frame, so the character drifts.
  • Generating an eight-frame cycle before a four-frame one works.
  • Accepting a generated background instead of asking for transparent.
  • Packing a sheet by hand when
    pack_sprite_sheet
    produces uniform cells deterministically.
  • 省略网格尺寸,然后尝试将柔和图像降采样为像素图。
  • 要求一次生成产出整张 sprite sheet。
  • 忘记排除抗锯齿和模糊,而这些正是模型的默认行为。
  • 在没有参考帧的情况下独立生成各帧,导致角色发生偏移。
  • 在四帧循环尚未成功之前,就尝试生成八帧循环。
  • 接受模型生成的背景,而不是要求透明背景。
  • 手动打包 sheet,而没有使用能够确定性生成统一单元格的
    pack_sprite_sheet
    .