Color shifting is a very fast, very simple effect that can greatly simplify the work of game artists. Here’s a demonstration (using a classic StarCraft Siege Tank):

For the record, I imagine this image is © Blizzard Entertainment...

Color shifting is trivial to implement - all we do is shift the red, green, and blue values of each pixel to the right (or left).  For example, a right-shift could work like this:

  1. Red -> Green
  2. Green -> Blue
  3. Blue -> Red

Note that the direction of the shift is somewhat misleading (as Windows DIBs, for example, encode color bits in BGR order), but the direction isn’t nearly as important as the effect - that without any extra work, we can generate two color variations on a source image.

Because gray-toned values have RGB values that are identical (or nearly identical), color shifting doesn’t change the appearance of gray pixels.  This is evident on the siege tanks above, as the color shifting merely adjusted the subtle hues of the gray regions.

However, the colored portion near the front of the tank changes drastically.  This is expected, since a sharply colored region must have large variations in its RGB values.

In video games where the same unit is available for multiple teams, races, or guilds, color-shifting can turn one base image into at least three possible team colors.  And, because color shifting is such a low-cost function, it can be easily performed on the fly - saving your artists work, and saving file bloat from redundant images.

Download the sample app and source code from GitHub