Providing HSL value in OpenGL

Hello All!

I have an image. When i open it in MS paint and check the values, i get the following:

Hue: 235
Sat: 145
Lum: 72

R: 122
G: 30
B: 41

It is a dark shade of Red. Now, i don’t know how i can provide the HSL values via GL. Can anyone please let me know how i can do this?

PS: I don’t know what the HSL values mean exactly. Any links would be really helpful. (From wiki, i read that its just another representation for RGB space. But i did not understand why we need the HSV space when RGB space is simpler)

Thanks in advance!

We use RGB because our eyes respond to these colors. Also our monitors emit just these colors. Other colormodels like HSL have one value dedicated for the brightness, the other encode the color. Hue here is the ‘pure’ color as you might find it on a rainbow, sat is the saturation, how ‘pure’ the color is. Lum is the luminance, the brightness if you want. Just play around with the color faders in paint to get a feeling for it.

If you need the HSL values in your shader (btw: why do you need them if you don’t even understand them?), you have 2 options:

  • calculate HSL in the shader from RGB (google will give you the formula)
  • provide the texture as HSL - just create a texture with H stored in R, S in G and L in B. OpenGL doesn’t care what the values in your texture mean and you can interprete them as you like.

Thanks for the reply Menzel.

>> btw: why do you need them if you don’t even understand them?

Well i was just curious about it.

>> Just play around with the color faders in paint to get a feeling for it.
I will, thanks for the suggestion.

Thanks!