//
//  Shader.fsh
//  GLSLTest
//
//  Created by Zenny Chen on 4/11/10.
//  Copyright GreenGames Studio 2010. All rights reserved.
//

varying vec2 TexCoordOut;

uniform sampler2D SamplerY;
uniform sampler2D SamplerU;
uniform sampler2D SamplerV;

void main(void)
{
    vec3 yuv;
    vec3 rgb;
    
    yuv.x = texture2D(SamplerY, TexCoordOut).r;
    yuv.y = texture2D(SamplerU, TexCoordOut).r - 0.5;
    yuv.z = texture2D(SamplerV, TexCoordOut).r - 0.5;

    
//    rgb = mat3( 1,       1,         1,
//               0,       -0.39465,  2.03211,
//               1.13983, -0.58060,  0) * yuv;
    
    rgb = mat3(      1,       1,      1,
               0, -.34414, 1.772,
               1.402, -.71414,      0) * yuv;
    
//    rgb = mat3(      1,       1,      1,
//               0, -.21482, 2.12798,
//               1.28033, -.38059,      0) * yuv;

    
    gl_FragColor = vec4(rgb, 1.0);
    
}
