Want to render with limited colors

Really elegant solution!

1 Like

Thanks. I just realized that it’s better to use rgb distance, (the original uses hsv) as really desaturated colors (near white) the hue is meaningless but may impose a harsh distance penalty. This rgb version works better at the extremes.
retro_composite_rgb.blend (1.2 MB)

1 Like

It’s a great solution, honestly. However, there seems to be a problem with the chains. It might just be my computer (my gpu is a 940 MX from 2016, RIP), but when I try to add some more chains in order to achieve a 16-color palette, the whole compositing process just comes to a screeching halt. I have no idea how much of this is my computer and how much is just… the ridiculous amount of node stacking I’m trying to perform.

This is a single group for 16 color palette, with a simpler node interface. The diff mask has been changed slightly and instead of mixing a new image, I’m using a math,minimum node, which might optimize it some. I have no idea if it will, or if if will use less memory. I would try it on smaller images first. This kind of stuff is easier to do through python, where we can optimize duplicate rgb values and look them up with a dictionary, instead of recalculating rgb distances, every pixel, every color. You can use this 16 color one with fewer colors, if you wanted just 3 colors you could make 4-16 the same as 3.

just append the retro_16 node group

retro 16blend on dropbox

3 Likes

Still kinda slow on my machine, but I don’t think I could ask for more, really. It’s already several times faster than whatever I had before, plus I have no Python knowledge whatsoever, lol. I could at least get it to render over 4 frames of an animation with a resolution of 224x192 in two or so minutes. Thanks a lot

1 Like

Here is a quick solution with snapping:
posterize.blend (109.7 KB)

Update: I’ve since then upgraded my setup dramatically, and with this new computer, this node group can now be baked into the footage in nearly 10 seconds. Seriously helps a lot with a project of mine, thanks once again.

Update: I’ve re-worked this node graph to compare and select the target colours in parallel (using in a binary tree structure), instead of doing them sequentially as @Photox made it. Tested it on renders up to 2048²px, and this optimization halves the compositing execution time. :slight_smile:

1 Like