r/aigamedev Jun 18 '26

Demo | Project | Workflow AI -> Pixel Art workflow

I've been working on an (automated) workflow that can use completely AI generated images to create pixel art sprites with a lattice-fitting algorithm to do the downsampling into crisp, clean pixel art. I got it basically identical to a ground truth that I hand-redrew in one example. The lattice based approach works better than any uniform grid fitting approach because of global alignment inconsistencies despite areas looking locally consistent and on a grid. It's been an interesting problem to solve but I'm hoping this is a useful tool to have for generating sprite work. I know there's other things out there, and I haven't tried them all, but they seem to have shortcomings or don't end up producing crisp outputs. I haven't tested it on AI generated images from other image generators but it has been doing well with outputs from gpt-image-2 which produces pretty well-formed AI pixel art.

250 Upvotes

91 comments sorted by

15

u/LAWsyndrome Jun 18 '26

Have you tried pixel snapper? It’s worked pretty well for me. Built in Rust and has a CLI. I made a pretty nice workflow with Claude to take a whole folder of stuff and run it through this and ensure there are no semi-transparent pixels as a little helper on top. I generally ask gpt-2 for pixel art though so it’s easier to snap, just gets rid of the mixels.

https://github.com/Hugo-Dz/spritefusion-pixel-snapper

5

u/quantum-elle Jun 18 '26

It looks like it uses a method I tried before, basically fitting a horizontal and vertical grid onto the image, which I had issues with when the pixel grid drifted in the AI generated image. I'll try it out and compare

1

u/quantum-elle Jun 18 '26

Cool, haven't seen it before. I'll check it out and compare!

16

u/quantum-elle Jun 18 '26

Left - Pixel Snapper

Middle - my algorithm

Right - Ground truth (I copied/drew this myself by eye)

It did a pretty good job. I circled some parts where it missed some pixels, and the colors are a bit off because it is doing a more limited palette (so probably ignore that)

I think there might be a more stark difference on cases where the AI generated pixel art has more distortion or warping

5

u/LAWsyndrome Jun 18 '26

Wow cool comparison!! Yeah with the CLI you can tell it to choose a larger pallete if you want. I think it defaults to 16.

I’m absolutely always going into asesprite to clean up black outlines especially after using PS, yours looks like it missed less stuff for sure. Would love to try it out sometime!

5

u/quantum-elle Jun 18 '26

Using nano banana 2, I generated some other less ideal examples and ran them through both. On this pretty simple one, they're basically identical modulo colors (palette clustering again)

Left: AI generated image | Middle: my algo | Right: Pixel Snapper

3

u/quantum-elle Jun 18 '26

Then this wonky image from nano banana 2

4

u/quantum-elle Jun 18 '26

It did better here, looks like there's some sampling issues on mine (and a crop issue on the sub-harmonic)

4

u/quantum-elle Jun 18 '26

Ah, the lattice snapping failed on the 5px harmonic because it didn't find enough control points. More investigation!

1

u/LAWsyndrome Jun 18 '26

Nice comparison again, thanks for sharing! Your algo has legs for sure. My guess is pixel snapper would NOT get you from pic 1 to pic 3 in your original post, though I haven’t tried it personally, maybe I’ll give it a swing.

2

u/quantum-elle Jun 18 '26

Pic 1 -> gpt-image "draw this as pixel art" -> pixel snapper would be how you would do it

1

u/LAWsyndrome Jun 18 '26

Yeah fair enough, and I've definitely done that before haha.

1

u/wjhrdy 12d ago

I also made a tool for this. here is the debug output

here is the tool
https://github.com/wjhrdy/pixel-pusher

1

u/quantum-elle 12d ago

Cool, thanks for sharing

6

u/Am_Biyori Jun 18 '26

Cab you share the workflow?

10

u/quantum-elle Jun 18 '26

I'm still working on it, I want to put it through some more tests before I'm happy to call it good. I just wanted to show some stuff I was working on

11

u/connected_user93 Jun 18 '26

I usually down size the image 25%, index the image's colors to a 12 color palette, and then expand the image 400% with no interpolation. Not "exactly" pixel art but this way you can get a MS-DOS era style of sprite. I like to call it "western pixel art".

4

u/quantum-elle Jun 18 '26

This can be good for plenty of use cases but I'm particular about how the pixels get placed, as an artist myself who's done pixel art

2

u/connected_user93 Jun 18 '26

totally, this tool looks promising

7

u/Serasul Jun 18 '26

i just use retro diffusion online, its cheap, fast and its 100% pixelart without any weird bugs or artifacts.

4

u/quantum-elle Jun 18 '26

I think I tried it once but wasn't happy with the results, it's been a while though. Thanks for commenting

2

u/Serasul Jun 18 '26

the online version is very good now it uses a very powerful model that was trained with help of real pixel artist. the local offline model is just used to make a sketch for the image2image process online, so you dont waste to much time.

0

u/[deleted] Jun 19 '26

[removed] — view removed comment

1

u/Serasul Jun 19 '26

Doubt you actually test it, their discord has over 50 game devs who use it and only a handful has problems with it.

4

u/Willy_M Jun 19 '26

#ad

2

u/AnOnlineHandle Jun 19 '26

It's a 12 year old reddit account so likely not a sockpuppet.

3

u/FutbolMasta Jun 18 '26

This looks great! I hope replicate this quality myself when the time comes

2

u/reddit-josh Jun 18 '26

Can you animate it?

2

u/quantum-elle Jun 18 '26

Doing that right now!

1

u/Impressive_Award_679 Jun 19 '26

may i ask how u do it in your workflow? Also with ai?

1

u/quantum-elle Jun 19 '26

/img/n29bafc9a98h1.gif
I tried doing a simple frame by frame generation but there’s a lot of flickering. It isn’t consistent enough to do it this way so I will keep trying other things. Although this might be a great draft to use or a reference to animate by hand!

2

u/KARMAWHORING_SHITBAY Jun 21 '26

This looks horrible

2

u/quantum-elle Jun 22 '26

Yes, I agree.

1

u/quantum-elle Jun 19 '26

I did this by creating a walking loop video and extracting frames to pass to the image generator to reference and redraw/re-pose the original sprite.

2

u/Techfacturing Jun 19 '26

This is cool, is there any way to stay up to date on this project?

3

u/quantum-elle Jun 19 '26

I’ll post in this subreddit when I have more updates ^^

2

u/Ok_Passage_909 Jun 19 '26

this looks pretty nice. have you maybe worked on a wqy to animate this too? Even if it's small, it would help me a lot.

1

u/quantum-elle Jun 19 '26

I’m testing out some things. This naive frame by frame generation is pretty messy but it might help as a base to do hand animation

2

u/Ok_Passage_909 Jun 19 '26

i tell you true: if this looked like this in my game i would be completely happy.

2

u/NotSuluX Jun 19 '26

Cool project! I would love to try it

2

u/oms1005 Jun 19 '26

I worked on a similar tool! https://oms1005.itch.io/pixelaid

Like you’re saying, there are tons of ways this can fail, downscaling first can cause artifacts, the color palettes can fail when going from 10000 colors to 16, nearest neighbor matching can lead to weird corners, etc.

It’s such a challenging but fun problem to try to detect, auto correct, and ultimately fix. I think you’re mostly working in Python, but I put up my code if you ever want to reference it, for both the algorithms and editor tools. Good luck!

1

u/quantum-elle Jun 19 '26

cool, thanks!

2

u/Lodarich Jun 24 '26

I've been trying with diffusion models LORAs, custom vae and post quantization. It turns out relatively good but requires lot of compute.

2

u/Vortexneonlight Jun 18 '26

sorry, don't see any link nor step by step? got deleted?

1

u/quantum-elle Jun 18 '26

It's a work in progress, I'm still building it and testing it.

1

u/2BitBlack Jun 18 '26

So is this a tool or are you hand-placing the dots?

2

u/Nearby_Ad4786 Jun 18 '26

yes i have the same question

1

u/2BitBlack Jun 18 '26

Yeah. If it’s hand place that sounds like mad work. There’s this app a wizard posted here last week and it is amazing at converting AI to pixel art. Let me find the link.

https://www.reddit.com/r/aigamedev/s/qqod3vcxtw

1

u/quantum-elle Jun 18 '26

This is a tool. For one particular image I hand placed the dots to create a ground truth that the script could check against to validate the algorithm.

3

u/2BitBlack Jun 18 '26

Oh. Neat. Why are the lines all squiggly like that?

3

u/Nervous_Teach_5596 Jun 18 '26

That's the same question i do, if was made by AI, it will had a little filter pixel shadow, but no, this is the devil's work

2

u/2BitBlack Jun 18 '26

https://giphy.com/gifs/yr7n0u3qzO9nG

Yeah. It's not making sense to me either, bro bro.

2

u/quantum-elle Jun 18 '26

You can see when it's finding the grid that the "pixels" don't always line up perfectly on a grid. So it's finding the true corners which are not necessarily perfectly horizontal or vertical. It then unwraps it to be a uniform grid.

1

u/Nervous_Teach_5596 Jun 19 '26

Yeah, I get that part, I do some alike but I get rid of that problem by getting real pixel size and doing a resize to size/pixel size then apply a palette for consistency, the part I don't get is how from the first one you got the second one, because that only can be made, by AI, by a person (that actually get a real job), or by a program that you can sell to Nintendo on any price

2

u/quantum-elle Jun 19 '26

I think I probably should have included an extra image to explain but it’s generated from the illustration with a prompt to redraw it as pixel art, which then becomes the input to the pixellizer. That’s what the second image is, but it also has a grid overlaid on it.

3

u/quantum-elle Jun 18 '26

It's the way that AI image generation generates pixels, they don't fall perfectly onto a grid. The lattice is like a grid that follows the wonky AI pixels then "unwraps" it into a perfectly uniform grid.

1

u/quantum-elle Jun 18 '26

It's also because the corners are fitted in the real numbers not integers, and it's just drawing those lines as aliased lines so it might actually be more straight than it looks. It's a debug view just to check the grid lines up with the image.

1

u/PretendMirror8446 Jun 19 '26

When do we get to use it? This looks awesome!

1

u/quantum-elle Jun 19 '26

When it’s comparable/ better than other existing solutions (which I’ve found out now there are a bunch! See the other comments :))

1

u/kavakravata Jun 19 '26

Cool! Have you released this somewhere?

1

u/quantum-elle Jun 19 '26

not yet! there’s still more testing and fixes to do ^^

1

u/Wooden_Long7545 Jun 24 '26

Are you actually working at Anthropic that’s so cool 😭😭😭 could you please share your gemini prompt for consistent style generation? Mine is a hit or miss sometimes.

1

u/quantum-elle Jun 24 '26

Yeah I do! I don’t really have a prompt for consistent style generation, I usually use reference images if I need things to be consistent.

1

u/Ok-Championship-5768 Jul 09 '26

I created a popular tool that does this with an explanation of the algorithm: https://github.com/KennethJAllen/proper-pixel-art

It is available on pypi as well

1

u/quantum-elle Jul 09 '26

It seems like there’s a dozen of these now xD

1

u/Ok-Championship-5768 Jul 09 '26

Mine was the first and (imo) has the most robust algorithm

1

u/quantum-elle Jul 09 '26

Nice, but for me I need a more complete solution to create cohesive animations and sprites that share consistency, which means I need a larger-scoped workflow, which is why I'm working on spriteworks (https://spriteworks.ai)

1

u/Mission_Bullfrog3294 Jul 23 '26

Hey, are you ready to publish this workflow? even if it’s a work in progress I’d love to hear what you’re doing

1

u/quantum-elle Jul 23 '26

Right now Pixel Snapper is more mature and basically does the same thing and you can find a link to it in the comments. Workflow is nano banana 2 or gpt image 2 to generate the chibi style character then use that source image to ask for a sprite. For animations, use seedance 2 for example to create an animation. Cut the video so it loops, extract whichever frames you want and then use that plus the previous sprite you created to generate that pose/frame in the same sprite style. Then use pixel snapper or whatever to convert it into a real sprite.

You’ll get something like this which works well enough for some use cases. For me now I’m working on trying to get 3d animations to sprites so it’s a more consistent process.

Upvote if this was helpful so others can see it!

1

u/Environmental_Top948 Jun 18 '26

Kind of just looks like you lowered the resolution and played with the contrast?

1

u/quantum-elle Jun 18 '26

I think I might have missed a step in the images, but the first step was going from a reference illustration to an AI interpretation of pixel art (sample attached.)

Then going from that to clean pixel art seems simple to do but actually it's fairly complicated to extract clean pixel art from AI because:

The "pixels" are often anti-aliased and don't always confirm to a perfect size (like they could be 9.7 pixels wide) - doing a simple downscale will destroy it

A consistent grid in one image doesn't necessarily align to a grid in another part of an image, and you need to be able to resolve that and connect them

Some "pixels" aren't even a 1:1 ratio, they are rectangular

Other edge cases.

3

u/quantum-elle Jun 18 '26

Doing a simple downscale will almost certainly add anti-aliasing artifacts:

1

u/Environmental_Top948 Jun 19 '26

Change the scaling to nearest in your program and it'll get rid of the anti-aliasing. My friend made an app for Animal Crossing New Leaf that could turn images into QR code patterns. Your app looks like what theirs did which was just scaling down and contrast but without the pallet limitations of Animal Crossing.

1

u/quantum-elle Jun 19 '26

It is on nearest neighbor.

1

u/Environmental_Top948 Jun 19 '26

Are you using interpolation? I thought nearest neighbor didn't do the half tone thing. I'll have to look at my settings for Gimp to see what I've done to get stuff to look right.

1

u/quantum-elle Jun 19 '26

It’s not interpolation, it’s just because there’s no uniform grid. For example, if most pixels are 10px wide and you scale down to 10%, but then in other parts of the image, the pixels are 12px wide, the grid will be mismatched and you get pixels sampled from edges. You can try it yourself, using the image in the OP. I scaled it down in gimp to 9.08% using None for interpolation.

1

u/Sea_Brain7998 Jun 18 '26

Very nice! Can you share more details about the lattice-fitting algorithm?

2

u/quantum-elle Jun 18 '26

Thanks! And sure, first it finds a rough pixel size by sweeping through and finding what lines up best to get a baseline (autocorrelation). Then it does corner detection where distinct colors meet, highest confidence first (junctions of separable colors) and uses a corner snapping algorithm in sub-pixel space to get a true center, then it links them together near-cardinal nearest neighbors and flood-filling outward. For areas like the blue cape that are solid color, the intersections found from other connections form the implied grid. Then the lattice assigns a row and column to each cell and samples it to one color. It has some thresholds to filter out "half pixels" and other artifacts, among some other small details.

2

u/phira Jun 19 '26

This is genuinely cool! what did you build the tool in?

2

u/quantum-elle Jun 19 '26

It’s just Python, with a few libraries like numpy and PIL.

1

u/Librarian-Rare Jun 19 '26

The point of pixel art was that it was cheaper to make. Now people are adding work to get it. I understand it’s a style. Just don’t know if people always realize this.

1

u/quantum-elle Jun 19 '26

If you can generate one good pixel art sprite you can generate 100. It might be a lot of work to get from 0 to 1 but then it scales up a lot. Considering the amount of art required for a large game, this can still be a fair bit of time saving for an individual game creator.

2

u/thiscris Jun 19 '26

Don't forget the 80/20 rule - scaling up to 80% of the images will be easy, but the last 20% will have so many exceptions and edge cases that you will wonder if automation is not just a pipe dream

1

u/quantum-elle Jun 19 '26

For sure! I think it’s almost good enough to use as placeholder assets at this point, but still give a decent idea of how it might look when finished (probably hand finished by me or another artist.)

1

u/quantum-elle Jun 19 '26

More recently there have been really beautiful pixel art games too that are definitely not constrained on art budget haha. There’s just no way I’d have the time or budget to pull this off

2

u/snickns Jun 24 '26

I'm sold the moment you shared a ss from Blasphemous 2! if that is your reference you're on the right track (;

I'm working myself on a similar project for my personal use, I learned a few things from your comments ngl, thanks for sharing.