PDA

View Full Version : GL_LUMINANCE problem



apapaxionga
08-28-2011, 03:55 AM
i read an article,it says that" if the value for a given texel is X,then the RGBA vector generated is GL_LUMINANCE:RGBA=(X,X,X,1)"

i do not understand it clearly,X should also have its own RGBA,so GL_LUMINANCE equals (RGBA,RGBA,RGBA,1)?

Can someone explain GL_LUMINANCE for me in detail?

BionicBytes
08-28-2011, 05:22 AM
Shaders read back 4 components using the .r, .g, .b or .a qualifiers. However, GL_LUMINANCE texture is just a single channel texture format. Therefore in your shaders when you read the tetxure using one of the sampler uniforms, the value you read will have been automatically applied to all qualifiers. In other words it does not matter if you sample your texture with tex.r, tex.g, tex.b or tex.a - all will have the same value.

apapaxionga
08-28-2011, 06:25 AM
GL_LUMINANCE texture is just a single channel texture format.
I want to know GL_LUMINANCE keeps which channel as the luminance value? (R,R,R,1) or (G,G,G,1) or (B,B,B,1)?

The Little Body
08-28-2011, 06:47 AM
The formula for to make the convertion from RGB to luminance is :



luminance = 0,299 * R + 0,587 * G + 0,114 * B


You can find more informations about this type of conversion at http://fr.wikipedia.org/wiki/YCbCr

BionicBytes
08-28-2011, 09:21 AM
Given the wording of your posts, either I'm not understanding you (highly likely) or your not understanding my answer.
GL_LUMINANCE makes the same channel data available across all channels during texture read. So (R,R,R,R) or R,G,B,A it does not matter as all channels are identical.

The Little Body
08-30-2011, 05:41 PM
With GL_LUMINANCE, alls channels have the same replicated value, cf. RGBA = (X, X, X, 1)


My previous formula is the reverse conversion which make the conversion from a color RGB triple values to his luminance value