31 lines
642 B
GLSL
31 lines
642 B
GLSL
uniform sampler2D y_tex;
|
|
uniform sampler2D u_tex;
|
|
uniform sampler2D v_tex;
|
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
void main()
|
|
{
|
|
const vec3 offset = vec3(-0.0625, -0.5, -0.5);
|
|
|
|
/* ITU-R BT.709 */
|
|
const vec3 Rcoeff = vec3(1.164, 0.000, 1.793);
|
|
const vec3 Gcoeff = vec3(1.164, -0.213, -0.533);
|
|
const vec3 Bcoeff = vec3(1.164, 2.112, 0.000);
|
|
|
|
vec3 yuv;
|
|
|
|
yuv.x = texture2D(y_tex, v_vTexcoord).r;
|
|
yuv.y = texture2D(u_tex, v_vTexcoord).r;
|
|
yuv.z = texture2D(v_tex, v_vTexcoord).r;
|
|
yuv += offset;
|
|
|
|
vec4 color;
|
|
color.x = dot(yuv, Rcoeff);
|
|
color.y = dot(yuv, Gcoeff);
|
|
color.z = dot(yuv, Bcoeff);
|
|
color.w = 1.0;
|
|
|
|
gl_FragColor = color;
|
|
}
|