For my opengl video player app, I am using surface texture bound to GL_TEXTURE_EXTERNAL_OES
In my fragment shader, I want luminance value to be taken for 3x3 block.
vec2 tex00 = vec2(vTextureCoord.x-xmargin, vTextureCoord.y-ymargin)
vec4 p00 = texture2D(sTexture, tex00)
... etc for 3x3
and then calculate luminance of each texel : ie: p00 by doing dot of p00.rgb with vec3 of (0.3,0.59,0.11).
Instead is it possible to directly use p00.y ? Will it give luminance value?
No, p00.y
is the same as p00.g
(or p00.t
). They are different ways to access the second component (green channel) of your vector. You can access components as XYZW, RGBA, or STPQ, and there is no difference between them.
The only reason that people use .rgb
instead of .xyz
is to make it easier for humans to read.