How do you blend multiple colors in HSV (polar) color-space?
Posted
by
Toxikman
on Game Development
See other posts from Game Development
or by Toxikman
Published on 2012-03-31T07:47:05Z
Indexed on
2012/03/31
17:45 UTC
Read the original article
Hit count: 185
In RGB color space, you can do a weighted multiple-color blend by just doing:
Start with R = G = B = 0. Then we perform a blend at index i using a set of colors C, and a set of normalized weights w like so:
R += w[i] * C[i].r
G += w[i] * C[i].g
B += w[i] * C[i].b
But I'd like to interpolate the colors in the HSV color-space instead, so that saturation and brightness are uniform across the interpolation. I know I can blend saturation and brightness in the same way as above, but the HUE component is an angle around a continuous circle, since HSV is essentially a polar coordinate system.
Blending only two HSV colors makes sense to me, you just find the shortest arc around the circle and interpolate between the two hues. But when you attempt to blend more than 2 colors, it becomes a bit of a puzzle.
You have to handle anomalous cases, like 4 equally-weighted colors with a hue at 0, 90, 180, and 270 degrees. They basically cancel each other out, so any hue will do.
Any ideas would be greatly appreciated.
© Game Development or respective owner