Sprite Stacking Skill Turns Four Pixel Art Drawings Into a Sprite You Can Spin
Daniel White's sprite-stacking skill takes four flat pixel art views of an object and turns them into a fake-3D sprite that rotates through every angle. It went up on GitHub on November 20, 2026, under an MIT licence, and installs into Anthropic's Claude Code, OpenAI's Codex, Anysphere's Cursor, SST's OpenCode, Google's Gemini CLI and Mario Zechner's Pi.
The technique is old. Indie developers have stacked sprites for years: slice an object into horizontal layers, draw them bottom to top, and lift each one by a pixel. Rotate every layer by the same angle and the pile reads as a solid object. White says as much in the README. What he added is a way to get those slices without drawing each one by hand, plus a workflow an AI coding agent can run start to finish.
Four views in, a slice strip out
The input is one image: top, side, front and back views in a single row on flat white. All four are orthographic, so no perspective and no 3/4 angle. The top view points the front of the object down. The side view points it left.
The slicer, a Python script called views_to_slices.py, handles the rest:
- Strips the background and the 1px outline around each view.
- Carves a voxel volume, keeping a voxel only where all four views cover it.
- Cuts that volume into flat layers, ground layer first.
- Renders each layer rotated, squashed for camera pitch, and lifted 1 px.
That carving step is a visual hull. If all four silhouettes agree a point is solid, it stays. If any one view rules it out, it's gone. No 3D model or voxel editor is involved at any point.
It has blind spots, and the skill documents them. A truck bed or a hollow arch doesn't show up in any of the four silhouettes, so it fills in solid and you fix those slices by hand. A raised rear spoiler that shows daylight in the side view survives fine.
What the agent does
You ask in plain language. "Make a rotatable pixel art car." "Sprite stack this 4-view sheet and give me a turntable." "Add a fake 3D pixel art tree to my Godot game."
The agent picks a path from there. Already have a slice strip or a layer export from MagicaVoxel, the free voxel editor by ephtracy? It skips to rendering. Have a four-view sheet? It checks the sheet, then carves. Starting from nothing, it generates the sheet with an image tool if one is connected, using a long prompt the skill supplies word for word. No image generator? It writes a short Python script with Pillow, the imaging library by Jeffrey A. Clark and contributors, and draws the four views itself, one pixel per art pixel, then upscales 8x with nearest-neighbour.
One rule sits near the top of the skill file: never ship a stack you haven't rendered and looked at. The slicer writes a check image with all four extracted views, four turntable angles and an exploded view. The agent has to open it before writing any integration code.
The numbers it won't let you guess
Most of the skill file is specifics. Two tiers set the size. Chunky retro runs 15 to 20 slices at roughly 25 by 48 px. Detailed hi-bit runs 26 to 44 slices, enough room for vents, logos and spoked rims.
Render settings come with reasons. Spacing is 1.0 screen pixel per slice at art scale. Squash is 0.75 for an angled top-down camera; 1.0 looks straight down, and below 0.6 the roofs flatten to slivers. Positions snap to whole pixels, because fractional offsets shimmer as the sprite turns. Filtering is nearest-neighbour everywhere.
Several rules came out of things breaking. Outline the finished stack once, never each slice, or seams and speckle run through the body. Y-sort whole stacks by their ground point and never interleave slices from two objects. Bake static stacks into flat sprites at load time. The skill does the math on that last one: 200 trees at 30 slices each is 6,000 draw calls a frame.
Engines covered
A reference file has drop-in code for web Canvas and Meta's React, Godot, the free engine started by Juan Linietsky and Ariel Manzur and now run by the Godot Foundation, Unity Technologies' Unity and Phaser Studio's Phaser. The Canvas version is about 25 lines of Microsoft's TypeScript. The Godot version is a Node2D whose turn property calls queue_redraw() when it changes, since Godot won't redraw the node otherwise. Unity gets one SpriteRenderer per slice with ascending sort order and Point filtering.
The slicer can also write a standalone viewer page with turntable, slice scan and exploded modes, drag to orbit, and export to a 16-direction PNG. The viewer opens on its own too. Drop a slice strip on it.
A lessons table built to shrink
The end of the skill file holds a Lessons table. Each row lists a mistake, the rule that avoids it, and what enforces that rule. When the agent produces a bad stack, it's supposed to change the slicer so the mistake can't recur (or make it warn), and add a test case built from the real failure. Once code covers a mistake, its row gets deleted.
Six rows were in the table at launch. Posts, ropes and antennas 1 px wide blink in and out as the stack turns, so the slicer now warns about them. Round parts narrower than their base, like a tower on a wide footing, carve square unless you pass the round flag. Background fully enclosed inside a view, between legs or fins, carves solid. Four of the six are still rules only.
Install
It needs Python 3 with Pillow and NumPy from the NumPy community. Install with Vercel's skills CLI (Node.js 22.20 or later):
npx skills add danielwh2/sprite-stacking
Add -g to install it for every project, or -a with an agent name (claude-code, codex, cursor) to target one. You can also copy the skills/sprite-stacking folder into ~/.claude/skills/ for Claude Code or ~/.agents/skills/ for the other agents.

No comments yet. Start the conversation.
Sign in to comment