b84499d4408b4c1a97ce41785f4e7104573b7ebb
[movit] / ycbcr_input.frag
1 // Implicit uniforms:
2 // uniform sampler2D PREFIX(tex_y);
3 // uniform sampler2D PREFIX(tex_cb);
4 // uniform sampler2D PREFIX(tex_cr);
5
6 vec4 FUNCNAME(vec2 tc) {
7         // OpenGL's origin is bottom-left, but most graphics software assumes
8         // a top-left origin. Thus, for inputs that come from the user,
9         // we flip the y coordinate.
10         tc.y = 1.0 - tc.y;
11
12         vec3 ycbcr;
13         ycbcr.x = tex2D(PREFIX(tex_y), tc).x;
14         ycbcr.y = tex2D(PREFIX(tex_cb), tc + PREFIX(cb_offset)).x;
15         ycbcr.z = tex2D(PREFIX(tex_cr), tc + PREFIX(cr_offset)).x;
16
17         ycbcr -= PREFIX(offset);
18
19         vec4 rgba;
20         rgba.rgb = PREFIX(inv_ycbcr_matrix) * ycbcr;
21         rgba.a = 1.0;
22         return rgba;
23 }