OK We have a working success. The key passed Y and UV as two separate textures to the fragment shader. Here is the final shader:
#ifdef GL_ES precision mediump float;
You will need to create your textures as follows:
int bufferHeight = CVPixelBufferGetHeight(cameraFrame); int bufferWidth = CVPixelBufferGetWidth(cameraFrame); glBindTexture(GL_TEXTURE_2D, videoFrameTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, bufferWidth, bufferHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddressOfPlane(cameraFrame, 0)); glBindTexture(GL_TEXTURE_2D, videoFrameTextureUV); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, bufferWidth/2, bufferHeight/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddressOfPlane(cameraFrame, 1));
and then pass them as follows:
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, videoFrameTexture); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, videoFrameTextureUV); glActiveTexture(GL_TEXTURE0); glUniform1i(videoFrameUniform, 0); glUniform1i(videoFrameUniformUV, 1);
Boy, I'm relieved!
PS The values for the yuv2rgb matrix are here http://en.wikipedia.org/wiki/YUV , and I copied the code here http://www.ogre3d.org/forums/viewtopic.php?f=5&t=25877 to find out how to get the right yuv values to start with.
davidbitton
source share