To give you an ad-free browsing experience, this website is completely funded by donations. If you use the information in this article to solve a problem, entertain yourself, or otherwise improve your life, please consider a small donation to help pay for server costs. Many thanks, and enjoy the site!

Game Code

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

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

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 tremendous file bloat from redundant images.

The project is coded in VB6, but an .exe is included for people who just want to play with the filter itself.

Download code (80kb)

 

BSD License
All source code in the above zip file has been released under a BSD License.

 

Related articles:

Discussion (Oldest Comments Displayed First)

Be the first to comment on “Color Shifting – 200% More Graphics for Free! (VB6)”

Post a comment

Feel free to use any of these tags in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>