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 6 of 6

Thread: Memory occupied by GL_LUMINANCE with 1 component

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2005
    Location
    Chennai, Tamil Nadu, India
    Posts
    26

    Memory occupied by GL_LUMINANCE with 1 component

    Hello,

    I am using a grayscale texture as an alpha map, and
    I store the texture in OpenGL with 1 component and image format
    as GL_LUMINANCE. This is working fine. When I tested this
    in NVIDIA Cg and performed a texture fetch, I'm able to access the
    alpha map with the r, g, b components.

    What I was wondering is: Does OpenGL use 3 components memory internally, even though I specified 1 component? Or do shaders generally work this way?

    If it uses 3 components internally, is there any way to make it use 1 component internally? (So that less memory is used?)

    Thanks in advance.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    999

    Re: Memory occupied by GL_LUMINANCE with 1 component

    Conversion to RGB
    This step is applied only if the format is LUMINANCE or LUMINANCE ALPHA. If the
    format is LUMINANCE, then each group of one element is converted to a group of
    R, G, and B (three) elements by copying the original single element into each of
    the three new elements. If the format is LUMINANCE ALPHA, then each group of
    two elements is converted to a group of R, G, B, and A (four) elements by copying
    the first original element into each of the first three new elements and copying the
    second original element to the A (fourth) new element.
    To answer your question. It uses 1 component internally but when accessing the texture it performs the conversion.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2005
    Location
    Chennai, Tamil Nadu, India
    Posts
    26

    Re: Memory occupied by GL_LUMINANCE with 1 component

    Thank you

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Re: Memory occupied by GL_LUMINANCE with 1 component

    To give you a bit of background info:

    GL_LUMINANCE and GL_ALPHA both use 1 component. However, when accessing a GL_LUMINANCE texture, all channels (R, G, B and A) do return the luminance value.
    When accessing a GL_ALPHA texture, R,G and B return 0 (or 1, not sure), and only the alpha-channel returns the value in the texture.

    This behaviour made sense back in the days, when we only had the fixed function pipeline.

    BTW: This is standard-behaviour with all textures. You can always read all 4 channels (RGBA), no matter, whether the texture has those channels, and the texture-fetch-unit will either reproduce one of the other channels values, or give you a default-value. E.g. when accessing the alpha-channel of an RGB texture, you will always get the value 1.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  5. #5
    Junior Member Regular Contributor
    Join Date
    Aug 2007
    Posts
    107

    Re: Memory occupied by GL_LUMINANCE with 1 compone

    Quote Originally Posted by Jan
    accessing a GL_LUMINANCE texture, all channels (R, G, B and A) do return the luminance value.
    Didn't you mean GL_INTENSITY in the above quote. With GL_LUMINANCE, all channels (R, G, B) except alpha return the luminance value.

    kinds regards,
    Nicolai de Haan Brøgger

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Re: Memory occupied by GL_LUMINANCE with 1 compone

    Yeah, i think you are correct. My point was just to explain why there are different formats, that seem to be identical.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

Posting Permissions

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