We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
eglGetError
precision mediump float;// Pass in the entire texture here.// E.g. a 256x256 video frame will actually be://// 256// +--------+// 256 | Y |// +--------+// + VU..VU |// 128 | VU..VU |// +--------+// // 256x384.uniform sampler2D u_s2dNV12;varying vec2 v_v2TexCoord;// This needs to be set from the application code.// E.g. for a 256 wide texture, it will be 1/256 = 0.00390625.uniform float u_fInverseWidth;void main(){ // Calculate the texture coord for the Y sample. vec2 v2YTexCoord; v2YTexCoord.s = v_v2TexCoord.s; v2YTexCoord.t = v_v2TexCoord.t * 2.0 / 3.0; // Sample the NV12 texture to read the Y component. float fY = texture2D(u_s2dNV12, v2YTexCoord).r; // Calculate the texture coord for the U sample. vec2 v2UTexCoord; v2UTexCoord.s = floor(v_v2TexCoord.s / 2.0) * 2.0 + u_fInverseWidth; v2UTexCoord.t = v_v2TexCoord.t * 1.0 / 3.0 + 2.0 / 3.0; // Sample the NV12 texture to read the U component. float fU = texture2D(u_s2dNV12, v2UTexCoord).r; // Calculate the texture coord for the V sample. vec2 v2VTexCoord; v2VTexCoord.s = floor(v_v2TexCoord.s / 2.0) * 2.0; v2VTexCoord.t = v_v2TexCoord.t * 1.0 / 3.0 + 2.0 / 3.0; // Sample the NV12 texture to read the V component. float fV = texture2D(u_s2dNV12, v2VTexCoord).r; // TODO: Insert YUV->RGB conversion maths here. gl_FragColor = vec4(fY, fU, fV, 1.0);}