# Cycling through colors with the same brightness

Ok. So I have a game I am working on with a bunch of colored particles. Each of them gets their own color however they are all close to a specific shade.

To explain that better I am using the HSV color space, and I have a global variable that is cycling from 0-360 (H) and each of the specific particles add or subtract a random amount from that.

I use HSV because it is the easiest way for me to cycle through colors because you can just change H.

This looks very nice and all, however the particles are supposed to be pure light that is colored. Right now all they are are circles colored with the shade, but later on I might add glow effects and other shading techniques.

The problem is that not all shades (I dont mess with H or V) are equal as far as the brightness our eyes see, and this causes problems. For example when all of them are shades of blue things look pretty dark.

Obviously in the shader I have to convert these HSV colors to RGB colors and doing some math I quickly saw what was wrong... the colors didn't have equal luminance!

As I understand it luminance is roughly (0.2126*color.r + 0.7152*color.g + 0.0722*color.b) which is why everything is off.

Is their a way to get it so I can still get all of the different chroma (colors on the wheels degrees) while maintaining a high luminance? Perhaps I should work with a different type of color then HSV, or perhaps their is a formula that finds a color at degree x on the color wheel with luminance of y?

Thanks much!

• There are limits to this unfortunately. If you look at a perceptually-uniform colour space like the Munsell colour system, you'll see that bright yellow has a much higher perceived value than a strong blue. That means if you want to keep uniform perceived value/luminance, then you can get either a rich royal blue paired with a dark ochre in the yellow hue, or a bright yellow with pale baby blue. Either way you sacrifice some saturation somewhere in the colour wheel. – DMGregory Feb 15 '16 at 15:17
• As you noted, RGB and HSL are designed around possible screen colors and not around human eyes. Take a look at HUSL and HCL. Sometimes I'll use L*a*b* too. – amitp Feb 15 '16 at 17:05
• @amitp those color spaces seem to be fairly new and I am seeing some difference in how they color spaces are defined, and how they are converted. Which source would be the most reliable for this? – J.Doe Feb 16 '16 at 6:25
• I'm on a bus, so I better not write a formal answer, but here's what lies underneath the problem: you're going to need to solve a equation system where you plug three variables: Hue, Luminance and Saturation. So here you're searching for a specific Value, given H and S, that meets the condition of having certain luminance. Not quite hard. But you'll soon find out that some colors can't get as luminous as some (try finding a blue as luminous as a 100V yellow), so you may want to clamp the values, in order to get values representable on the screen. – Gustavo Maciel Feb 18 '16 at 0:40
• Yeah I've been working on that. I got a recursive formula going... AND a non recursive one (that isn't quite working). – J.Doe Feb 18 '16 at 0:43