Fixing Uneven AI Sprite Sheets: Grid, Duplicates, Alignment
An AI model asked for a sprite sheet will usually paint something that looks like a grid. It is not a grid. Cells drift by a few pixels, the gap between columns changes, one pose is missing, two frames are identical, and a sword floats slightly outside its cell.
Slicing that image with a uniform grid produces cut-off limbs and a character that jumps. This guide is about repairing the sheet instead of pretending it is regular.
If you want the tool while you read, it is here: AI Sprite Sheet Fixer.
Why AI sheets are uneven
The model is not laying out a grid. It is generating an image that resembles the idea of a sprite sheet: repeated poses, roughly in rows, roughly the same size. That produces four predictable failures:
| Failure | What it looks like | Why it happens |
|---|---|---|
| Drifting cells | Rows are not evenly spaced; a pose crosses into the next cell | The model paints by composition, not coordinates |
| Missing pose | A walk cycle has 6 frames instead of 8 | The model drops a step it cannot fit |
| Duplicate pose | Two frames are pixel-identical | The model repeats a pose to fill space |
| Detached parts | A sword, shadow, or effect sits away from the body | No concept of a single sprite boundary |
A grid slice cannot fix any of these. You need to find the actual content first.
Diagnose in 60 seconds
Before touching a tool, look at the sheet at 100% and answer:
- Is there a consistent cell size? Draw an imaginary grid. Do the feet line up on a baseline?
- Does any sprite cross a cell border? If yes, the grid is wrong at that column or row.
- Are any frames identical? Flip between adjacent poses.
- Is the background one flat color? If it is painted, fix the background first.
If the answer to (1) is “mostly,” grid mode is fine. If it is “no,” use auto-detect.
Three repair strategies
1. Grid slice — when the sheet is almost regular
Use this when the model respected the layout and only the content inside each cell is imperfect.
- Set columns and rows to the intended sheet layout.
- Set margin and spacing if the sheet has a border or gutters.
- The tool finds the content inside each cell and trims to it.
The risk: one wrong column count cuts every sprite in that column.
2. Auto-detect — when the layout is fictional
This is the reliable path for AI sheets. The tool:
- Samples the corner color as the background.
- Builds a foreground mask (alpha or color distance).
- Finds connected regions.
- Merges nearby regions into one frame.
- Filters regions below a minimum area.
- Sorts them in reading order.
Use auto-detect when the sheet has a flat or transparent background and the sprites are separated by at least a few pixels.
3. Rebuild uniform cells — always
Detection gives you regions; it does not give you an animation. Every region must be placed into a cell of the same size, or the character will shift when the engine plays the frames.
The rebuild step:
- Takes the largest detected region as the target cell.
- Centers every other region inside that cell.
- Adds padding (2 px is a good default).
- Packs the cells into a grid that fits the texture limit.
That is the difference between “I cut the sprites” and “I have an animation.”
Step by step in the fixer
- Load the sheet. A transparent PNG is easiest; a flat JPG works if the background is one color.
- Pick Auto-detect unless you know the exact grid.
- Set the background tolerance. Raise it until the background disappears. If the character starts to erode, you went too far.
- Set the minimum area. Raise it to ignore specks and stray pixels. A value around 0.05% of the image is a reasonable start.
- Set the merge gap. Increase it when a sword, shadow, or detached hand becomes a separate frame.
- Check the boxes. The preview numbers each region. If two characters are merged into one box, the gap is too large or the sprites touch in the source.
- Turn on duplicate removal only if the sheet repeats poses. Leave it off for intentional holds.
- Build and check the preview. Every cell should be the same size and the character should sit on the same baseline.
- Download PNG + JSON, then use the SpriteFrames generator for Godot.
The failure cases, and what to change
| Symptom | Cause | Fix |
|---|---|---|
| Sword is a separate frame | Detached part | Raise merge gap by 2–6 px |
| Tiny specks become frames | Noise or JPEG artifacts | Raise minimum area |
| Two characters become one frame | They touch, or merge gap is huge | Lower the gap; use grid mode |
| A frame is missing | The model omitted a pose | Duplicate a nearby pose or regenerate that frame |
| Frames are in the wrong order | Model laid them out right-to-left or in columns | Rename/reorder in the sheet maker before building |
| Character jumps between cells | Different region sizes, no uniform bounds | Rebuild with uniform cells; check the pivot |
| Halo around the sprite | Background color remains on the edge | Use the background remover with contract + threshold |
Alignment is not the same as trimming
Trimming finds the visible pixels. Alignment decides where those pixels sit relative to the character’s origin.
For a side-view character, the usual setup is:
- Uniform cell size across every frame.
- Bottom-center pivot at
(0.5, 1.0). - No per-frame nudging; if the character drifts, fix the whole sequence or the source.
In Godot, AnimatedSprite2D does not store a per-frame pivot. It uses the node’s centered flag and offset. That is why uniform cells matter: one offset has to work for every frame. The full import path is in Godot 4: SpriteFrames from a sprite sheet.
A pre-flight checklist
Before you export, confirm:
- Every cell has the same width and height.
- The character’s feet sit on the same baseline.
- No frame is cut off at the cell edge.
- No duplicate frames unless the hold is intentional.
- The background is transparent, with no colored fringe.
- The JSON frame count matches the intended animation.
- The sheet is within the engine’s texture limit (2048 or 4096 is safe).
If a box fails, fix it before importing. Engines are forgiving about a lot of things; they are not forgiving about a sprite that jumps.
FAQ
Can I fix a sheet with a painted background? Not with a color key. Remove the background with a matte first, then fix the grid. Auto-detect assumes a flat or transparent background.
Should I use grid or auto-detect for a 4×4 AI sheet? Try auto-detect first. If the model respected the layout, grid mode is faster; if the boxes look wrong, auto-detect is more reliable.
Why does duplicate removal delete a frame I wanted? It compares a small grayscale signature; two poses that look similar at low resolution can match. Turn it off for holds and reactions.
Can I keep the original order? Auto-detect sorts in reading order. If the model painted columns or right-to-left, rename the frames in the sheet maker before rebuilding.
Does this work for a single sprite? Yes, but the tool is built for a sequence. For one sprite, the background remover is usually enough.
Next: Why AI animations flicker — the frame-to-frame problems a grid fix cannot solve.