How to pass YUV data into a fragment shader without GL_LUMINANCE

1.4k views Asked by At

In Android, in order to pass YUV420sp into a fragment shader I pass the information spliting the data into Y-U-V, and passing each sugin glTexImage2D with GL_LUMINANCE format

But now I need to do Offscren-Rendering for which I require FBOs, the problem is that FBOs do not support GL_LUMINANCE.

So what would be the best way to pass the YUV data without using GL_LUMINANCE?

By the way, I cannot process the YUV in the CPU and convert it to RGB or something else, as the whole point is to pass the YUV as it is into the GPU.

EDIT: As this is for android, the single channel GL_RED will not work as such has not been implemented.

1

There are 1 answers

2
Andon M. Coleman On BEST ANSWER

GL_LUMINANCE is completely unnecessary in the programmable pipeline.

At its most basic level, it was a hack that allowed texture swizzling in the days of the fixed-function pipeline. These days you use GL_RED for a single-channel texture and you can swizzle it any way you want in your fragment shader.

What you want to duplicate GL_LUMINANCE is: vec4 (texture (...).rrr, 1.0). You can even do this in the fixed-function pipeline in recent OpenGL implementations using ARB_texture_swizzle.