Some insights about pixel art color ramps
Note: This is intended for beginner and intermediate level pixel artists. If you're advanced, you probably already know this stuff, so feel free to correct me.
In a recent late-night coding binge, I wrote the color gradient generator for the Dawnbringer 32 palette that I posted here in another thread. The process of writing it was kind of trial and error, but with a lot less error than I expected. That is, pretty much everything I tried worked better than I thought, and the things that I did that worked well can be translated into practical pixel art advice.
First off, a couple of things I already knew:
One, pixel art color ramps actually look the most natural if there's a bit of color variation in them. I'm told that this is because in real world lighting situations, there's light bouncing off of all sorts of things, so objects in the real world are lit from different directions by many different colors (although the brightest color will always be the color of the source of illumination, generally the sun or a lamp). If you vary the hues in your color ramps just a bit, you can simulate the effect of these different colors bouncing around and contributing subtle hues to your illumination.
Two, I learned by observing Surt and Buch that sometimes changing one single color in a color ramp can make you perceive the color of an object completely differently. To see this in action, take a close look at the bottom row of items in this puzzle game tileset by Surt, taking special note of the fact that the grey that is the main color of most of the items on the bottom row is used as the main color in nine different sets, yet each one of those sets appears to have a completely different color. The point is, when you look at a properly shaded object done in a pixel art style, your brain doesn't process the individual pixel colors, it processes all of the colors used to shade the object, and then decides what color it is.
So, armed with these two bits of knowledge (and knowing that I'm not good at coming up with these kinds of nice color ramps on my own) I set out to write a color ramp generator. Here is a simplified explanation of how it works: You start by choosing the color of the object that you want to light. Then, you choose the color of the main light source, and finally you choose the color of them ambient light in the scene. Doing a little bit of color math, the program simulates putting an object in the lighting environment that you set up, and comes up with a gradient (from light to dark) of all the different colors that would result.
So here's where things get interesting: The next thing the program does is pick five colors from Dawnbringer's 32 color palette, from light to dark, that best match the gradient. Now, 32 colors is a fairly limited palette, so one issue I kept running into were that some resulting color ramps had the same color duplicated 2 or 3 times out of five colors, which didn't look very good. So on a lark, I decided that, once a color was included in a ramp, it was "off limits" for matching the rest of the ramp, and so rather than duplicating a color, I would match the *next closest* color in the ramp.
The results of this looked kind of bad, but I noticed that what was bothering me was the fact that some of that shadow colors were actually a bit lighter than some of the highlight colors, because the program was being forced to reach a bit further around the palette to find a match. So, rather than giving up on this idea, I decided to try sorting the final color ramp by luminosity. Naturally, the result of this is that some of the colors matches are pretty far away from the original colors, so I was very surprised to discover that it actually worked really well.
So, the big thing I learned from this is that when you're making color ramps, luminosity is pretty much the most important thing to watch out for. While hue is somewhat important, it's secondary to luminsity, to the point where it's okay to sacrifice an accurate hue in favor of accurate luminosity.
Anyway, I hope some people find this useful. I'd be interested if anyone has any more thoughts on it.
Bart
Good write-up. I've been analyzing Redshrike's stylized versions of some Heroine Dusk monsters:
http://opengameart.org/content/heroine-dusk-first-person-dungeon-crawl-enemies-remixed
That's all using DawnBringer's 16 color palette. I've been trying to study his technique analytically, like you're doing in this post. I noticed there too that luminosity is more important than hue in many places.
An aside; something Dawnbringer did intentionally with these palettes is make the brighter colors yellower and the darker colors purpler. It almost makes it so that you can choose any color ramp based just on luminosity, and the hues will work together to make a correctly lit material.
One important thing about palettes is that, as they get further from neutral luminosity saturations become less and less intense. So saturation differences are a lot easier to fit. Greys are also generally useful for binding disparate colors together, which is one reason for the focus on them.
When it came to working on the Heroine Dusk critters, though, most of it was pretty experimental. If a ramp felt like it needed a color for anti-aliasing I'd pick one that seemed like it might work and try it. If there wasn't one that was suitable I tried to arrange the clusters to minimize how obvious it was.