Sign in to follow this  
xelanoimis

About HSL to RGB with HDR values

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this