# About HSL to RGB with HDR values

This topic is 4303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I have to do a color picker that must be capable of returning HDR rgb values, meaning I can have values bigger than 1.0 (or smaller than 0.0) for color components, to use in graphic shaders with HDR. I have edit controls where I can type the values in RGB directly, but I would like to add a HSL option so I can switch between the two formats. Does anyone knows how to convert between HSL and RGB using non-clamped values? All conversion algorithms I've seen are using clamped values (0.0-1.0 or 0-255), but I need the conversion to be bijective. In the classic algorithms if I give a luminance of 1.0 any color will be converted to 1,1,1 and when I want back in HSL ... you got the point. So, if anyone did this or have a useful link, I would help me save some time diging it. Thanks!

##### Share on other sites
http://www.easyrgb.com/math.php?MATH=M19#text19

Use values between 0..1 for your RGB and ignore the 255 in the formulas. Anyway, when dealing with HDRI, 0..1 feels more natural IMO.

##### Share on other sites
I have the same conversion implemented, but it doesn't seem to work as I expected with values higher than 1. Maybe they can't be converted like that at all.

H=0,S=1,L=0.5 is converted into R=1,G=0,B=0 (as expected), but
H=0,S=1,L=1 is converted into R=1,G=1,B=1 (I was expecting a high red, like R=2)
H=1,S=1,L=0.6 is converted into R=1,G=0.2,B=0.2 (the same thing I was expecting a R>1, G=0 B=0)
not to mention when I set L=2 or higher

The artists would like to edit the color in HSL, setting a heigher luminance and receive an echivalent in RGB (with values heigher than 1), but keeping the hue and saturation.

I'm not sure this conversion is suitable for HDR colors, since a R=1.5,G=0,B=0 would look like a very intense red, but a H=0,S=1,L=0.7 is some kind of pink.

Anyway, if you know of a program that have a nice HDR color picker (that allows values higher than 1.0), let me know.

Thanks

##### Share on other sites
Have you considered working with HSB/HSV color space?
It should be much more intuitive both to you and your artists (since this is the color space used in photoshop).

The conversion formulas provided by fboivin, should work for any positive RGB values. Please note that H and S will still be mapped into the [0..1] range, while the B (brightness) value will be mapped into [0..inf], which is pretty much what you are looking for.

1. 1
2. 2
frob
17
3. 3
4. 4
5. 5

• 20
• 13
• 14
• 76
• 22
• ### Forum Statistics

• Total Topics
632140
• Total Posts
3004373

×