Generating Pixel Desktop Pet Animation Assets via a Multi-Agent Pipeline

    Creating animation assets for desktop pets requires balancing character consistency, fixed frame counts, and background transparency. A single image generation call often fails to meet these constraints simultaneously. This article explores a multi-agent pipeline designed to generate pixel art sprite atlases for desktop pets. By decomposing the task into identity locking, master-worker agent division, strict manifest constraints, and automated post-processing scripts, the pipeline ensures reliable, consistent, and ready-to-use asset generation.

    1. Problem Definition

    Desktop pets typically reside on the screen, displaying continuously playing animations. To transition between different states, they usually require a sprite atlas. The atlas arranges the frames of all actions in a fixed grid layout on a single image, allowing the program to extract the corresponding frames using row and column coordinates for playback.

    The difficulty in producing these assets lies not in visual aesthetics, but in satisfying four constraints simultaneously:

    1. Action Completeness: Must cover all necessary actions, such as idle, move, interaction feedback, and status prompts.
    2. Fixed Frame Count: The number of frames per row must be declared in the manifest to ensure correct looping at runtime.
    3. Transparent Background: Each frame requires pixels with an alpha channel; otherwise, color blocks will appear around the pet’s edges.
    4. Character Consistency: All actions must feature the same character. Hair, body shape, and color schemes must not drift across different rows.

    A single image generation call rarely meets all four criteria. The resulting images often suffer from body shape drift, incorrect frame counts, and unclean backgrounds. Therefore, the task must be broken down into verifiable steps, ensuring each step has clear inputs and outputs.

    2. Locking Character Identity First

    Character consistency is the starting point of the entire pipeline. The approach is to generate a primary reference image first and write its key features into a reusable identity description.

    The reference image is used to extract key variables rather than to make the model copy it pixel by pixel. For example, for a small-proportion character with black hair, a slender figure, and a mature vibe, the key variables include:

    • Overall body proportion: waistline, leg length, and head-to-body ratio
    • Hairstyle and hair color: outline and primary color
    • Primary color of the clothing, rather than every detail
    • Style constraints: pixel readability, line thickness, and shading method

    A common issue with the first version of the primary image is that the design is too round, resulting in a short, chubby, dough-like figure. The adjustment method is to add explicit negative constraints in the prompt, such as forbidding short/chubby body types, forbidding child-like big heads and short legs, and requiring a slender proportion. Additionally, the prompt should forbid bringing UI text, grid lines, or layout elements from the reference image into the result.

    Once the primary image is finalized, lock its description. All subsequent action generations will reuse this exact identity description. The more specific the description, the smaller the deviation between sub-tasks.

    3. Master and Sub-task Division

    The pipeline employs a two-layer agent structure.

    The master agent is responsible for global control:

    • Maintaining the action manifest, defining the action name, frame count, FPS, and loop property for each row
    • Dispatching sub-tasks and recording the inputs and status of each sub-task
    • Aggregating outputs and coordinating the final packaging and quality checks

    The sub-agents are responsible for single-row actions:

    • Each sub-agent generates only one action row
    • Receiving the unified identity description and the specific action instructions for that row
    • Outputting a fixed number of frames with corresponding sequence numbers

    This division provides failure isolation. If a certain row’s output is unsatisfactory, only that row needs to be re-run, eliminating the need for a complete overhaul. Generating rows in parallel also reduces overall time consumption.

    4. Constraining All Steps with a Manifest

    The manifest is the contract for the pipeline. It describes the format specifications without including any specific visual details. Below is an example configuration. The parameters are demo values; actual values should be determined based on the runtime environment and display requirements:

    1. {
    2. "asset_id": "desktop_companion_demo",
    3. "cell_width": 192,
    4. "cell_height": 208,
    5. "background": "transparent",
    6. "animations": [
    7. {"name": "idle", "row": 0, "frames": 6, "fps": 6, "loop": true},
    8. {"name": "move", "row": 1, "frames": 8, "fps": 10, "loop": true},
    9. {"name": "wave", "row": 2, "frames": 6, "fps": 8, "loop": false},
    10. {"name": "jump", "row": 3, "frames": 6, "fps": 10, "loop": false},
    11. {"name": "error", "row": 4, "frames": 6, "fps": 8, "loop": false},
    12. {"name": "waiting", "row": 5, "frames": 6, "fps": 4, "loop": true},
    13. {"name": "working", "row": 6, "frames": 8, "fps": 8, "loop": true},
    14. {"name": "review", "row": 7, "frames": 6, "fps": 6, "loop": true}
    15. ]
    16. }

    The manifest provides three main benefits:

    1. It establishes an acceptance standard for sub-task outputs; if the frame count doesn’t match, it fails immediately.
    2. The packaging script does not need to guess the grid structure; it can slice the atlas directly based on the manifest.
    3. The playback client only needs to read the manifest to know the frame count and loop behavior of each row.

    The manifest should also record the total dimensions of the atlas. The atlas width equals the maximum frame count multiplied by the cell width, and the height equals the number of rows multiplied by the cell height. Unused cells can remain fully transparent.

    5. Scripting Layer Processing Steps

    The output of the sub-agents is usually a full grid image or a sequence of single frames, which requires post-processing via scripts. The recommended sequence is as follows:

    1. Frame Extraction: If the output is a full grid image, slice out the individual frames according to the manifest’s row and column rules, and verify that the frame count matches the manifest.
    2. Transparency Processing: Convert the solid background into an alpha channel and apply slight feathering to the edges to prevent aliasing. The background color should be specified in the prompt as a solid color that does not overlap with the character’s color scheme (e.g., highly saturated green or magenta) to facilitate easy keying.
    3. Size Normalization: Crop all frames uniformly to the cell size and align the character’s feet to the same baseline to prevent up-and-down jumping during playback.
    4. Atlas Assembly: Write the frames into the large image according to the row and column order, keeping empty spaces fully transparent.
    5. Output Manifest Copy: Output alongside the atlas to ensure version consistency between the two.

    Below is pseudocode illustrating the above steps:

    1. function build_atlas(manifest, row_outputs):
    2. atlas = blank_canvas(width = max_frames * cell_w,
    3. height = rows * cell_h,
    4. alpha = 0)
    5. for anim in manifest.animations:
    6. frames = extract_frames(row_outputs[anim.name], anim.frames)
    7. assert length(frames) == anim.frames
    8. for i, frame in enumerate(frames):
    9. frame = remove_background(frame, key_color)
    10. frame = align_baseline(crop_to_cell(frame, cell_w, cell_h))
    11. paste(atlas, frame, x = i * cell_w, y = anim.row * cell_h)
    12. save(atlas, "atlas.png")
    13. save(manifest, "manifest.json")

    The assertions in the code are critical. Frame count validation and baseline alignment are the two most easily overlooked steps, yet they have the most significant impact on visual quality.

    6. Quality Check

    Quality inspection is divided into two layers: structural checks and visual checks.

    Structural checks are completed automatically by scripts:

    • Whether the atlas dimensions match the theoretical size calculated from the manifest
    • Whether the valid frame count for each row matches the declaration
    • Whether the alpha channel exists and if there is any non-transparent residue at the cell edges
    • Whether the file can be properly read and decoded

    Visual checks rely more on manual inspection or model-assisted verification:

    • Whether the character identity remains consistent, including hairstyle, body shape, and primary colors.