Skip to content

Instantly share code, notes, and snippets.

@jeiting
Created September 10, 2012 00:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeiting/3688050 to your computer and use it in GitHub Desktop.
Save jeiting/3688050 to your computer and use it in GitHub Desktop.
YcRcBA Compositing with GLSL
varying highp vec2 v_texCoord;
uniform sampler2D u_YTex;
uniform sampler2D u_cRTex;
uniform sampler2D u_cBTex;
uniform sampler2D u_ATex;
void main()
{
const lowp mat3 M = mat3 (1.164, 1.164, 1.164,
0.0, -0.3917, 2.01723,
1.5960, -0.812, 0.0);
const lowp vec3 postBias = vec3(-0.870, 0.529, -1.0813);
lowp vec4 p;
lowp float Y = texture2D(u_YTex, v_texCoord.st).x;
lowp float cB = texture2D(u_cBTex, v_texCoord.st).x;
lowp float cR = texture2D(u_cRTex, v_texCoord.st).x;
lowp float A = texture2D(u_ATex, v_texCoord.st).x;
p.a = A;
p.xyz = M * vec3(Y,cB,cR) + postBias;
gl_FragColor = p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment