#version 330 core

in vec3 vertexColor;    //输入颜色数据
in vec2 TexCoord;       //输入纹理坐标数据

out vec4 FragColor;     //输出颜色数据

uniform sampler2D textureY; //Y分量纹理采样器
uniform sampler2D textureU; //U分量纹理采样器
uniform sampler2D textureV;

void main()
{
    float y = texture(textureY, TexCoord).r;
    float u = texture(textureU, TexCoord).r - 0.5;
    float v = texture(textureV, TexCoord).r - 0.5;
    float r = y + 1.402 * v;
    float g = y - 0.344 * u - 0.714 * v;
    float b = y + 1.772 * u;
    FragColor = vec4(r, g, b, 1.0);
}
