mbebenita/Broadway — comment on commit 560145551938358ff4ad7e25985ff70bd64c9867
File: Demo/broadway.html line 233
By p01:

No need to use integer maths and clamping in the fragment shaders. GPU excel at processing floats and gl_FragColor is saturated. You can just use the following fragment shader:

#ifdef GL_ES
precision highp float;
#endif

varying highp vec2 vTextureCoord;

uniform sampler2D YTexture;
uniform sampler2D CbTexture;
uniform sampler2D CrTexture;

void main(void) {
vec3 YCbCr = vec3
(
texture2D( YTexture, vTextureCoord ).x*1.1643828125, // premultiply Y
texture2D( CbTexture, vTextureCoord ).x,
texture2D( CrTexture, vTextureCoord ).x
);

gl_FragColor = vec4
(
YCbCr.x+1.59602734375*YCbCr.z-0.87078515625,
YCbCr.x-0.39176171875*YCbCr.y-0.81296875 *YCbCr.z+0.52959375,
YCbCr.x+2.017234375 *YCbCr.y-1.081390625,
1
);
}