// __multiversion__
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.

#include "shaders/fragmentVersionCentroidUV.h"
#include "shaders/uniformMacro.h"

varying vec4 ColorOut;
varying vec4 AdditionalOut;

uniform sampler2D TEXTURE_0;
uniform sampler2D TEXTURE_1;
uniform sampler2D TEXTURE_2;

void main() {
	vec3 YCbCr;
	YCbCr.x = texture2D(TEXTURE_0, AdditionalOut.xy).a;
	YCbCr.y = texture2D(TEXTURE_1, AdditionalOut.xy).a;
	YCbCr.z = texture2D(TEXTURE_2, AdditionalOut.xy).a;

	YCbCr -= vec3(0.0625, 0.5, 0.5);
	mat3 yuv2rgb = mat3(vec3(1.164, 1.164, 1.164), vec3(0, -0.391, 2.018), vec3(1.596, -0.813, 0));
	vec3 rgb = yuv2rgb * YCbCr;

	float alpha = ColorOut.a;
	gl_FragColor = vec4(rgb * alpha, alpha);
}
