A while ago a colleague of mine challenged me and a couple of others at work to come up with an algorithm for the ‘AllRGB’ challenge.

You can find the website for it here:

As the website states, ‘The objective of allRGB is simple: To create images with one pixel for every rgb color (16777216); not one color missing, and not one color twice.’


So what that boils down to is a 4096×4096 8bpp image which contains every possible R-G-B combination, similar to this 512×512 6bpp version:

This is my first implementation, using an algorithm which borrows ideas from the simulated annealing algorithm.

This is the C# app I wrote for testing it. No fancy compute shaders or anything, this is running on CPU and is not multi-threaded yet. At the moment it calculates 6bpp 512×512 images. This is just so I can test different approaches quicker. The same principle can be used for 8bpp 4096×4096 images, of course.

The input image I use to test with most (by Tiago Hoisel) looks like this:

The output image (which takes about 20 seconds to generate) is this horrible mess of too over saturated colours, but it contains 512×512 unique 6bpp colours:

Better coloured results can be achieved by randomizing the pixels more, but the tradeoff is you start to lose details.