0

For my opengl video player app, I am using surface texture bound to GL_TEXTURE_EXTERNAL_OES

source : https://github.com/crossle/MediaPlayerSurface/blob/master/src/me/crossle/demo/surfacetexture/VideoSurfaceView.java

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?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
deeps8us
  • 75
  • 1
  • 9

2 Answers2

1

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.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
  • oh nice. if that is actually what he asked this is great! i never thought that y==luma could be implied. – starmole Mar 29 '16 at 10:27
0

No, but maybe close enough for your use case. By just using y you will miss some cases though. A pure red image would be 0. You can add up all 9 samples though and do one dot product on the result.

starmole
  • 4,974
  • 1
  • 28
  • 48