View Full Version : Memory occupied by GL_LUMINANCE with 1 component
04-08-2008, 03:34 AM
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.
04-08-2008, 04:19 AM
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.
04-08-2008, 05:41 AM
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.
Nicolai de Haan
04-08-2008, 11:57 AM
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.
Nicolai de Haan Brøgger
Yeah, i think you are correct. My point was just to explain why there are different formats, that seem to be identical.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.