- Tanner Helland (dot) Com - http://www.tannerhelland.com -

Color Shifting – 200% More Graphics for Free! (VB6)

Posted By Tanner On January 23, 2009 @ 12:00 am In Game Code,Graphics Code,Programming | Comments Disabled

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 relatively simple 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 so

  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 pretty clear 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.

Can you see the obvious game design implication?  :)  If your game has the same unit 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.


Article printed from Tanner Helland (dot) Com: http://www.tannerhelland.com

URL to article: http://www.tannerhelland.com/474/color-shifting/

All text copyright © 2008 Tanner Helland. To reduce paper and ink usage, all comments, images, and videos have been suppressed on this printing.