Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Providing HSL value in OpenGL

  1. #1
    Intern Contributor
    Join Date
    Jan 2012
    Posts
    81

    Arrow 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!

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    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.

  3. #3
    Intern Contributor
    Join Date
    Jan 2012
    Posts
    81
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •