Skip to content

Instantly share code, notes, and snippets.

@dlublin
Created November 19, 2017 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlublin/90f879cfe027ebf5792bdadf2c911bb5 to your computer and use it in GitHub Desktop.
Save dlublin/90f879cfe027ebf5792bdadf2c911bb5 to your computer and use it in GitHub Desktop.
GLSL shader that performs YCoCg conversion and can be used for drawing Hap Q frames.
uniform sampler2D cocgsy_src;
const vec4 offsets = vec4(-0.50196078431373, -0.50196078431373, 0.0, 0.0);
void main()
{
vec4 CoCgSY = texture2D(cocgsy_src, gl_TexCoord[0].xy);
CoCgSY += offsets;
float scale = ( CoCgSY.z * ( 255.0 / 8.0 ) ) + 1.0;
float Co = CoCgSY.x / scale;
float Cg = CoCgSY.y / scale;
float Y = CoCgSY.w;
vec4 rgba = vec4(Y + Co - Cg, Y + Cg, Y - Co - Cg, 1.0);
gl_FragColor = rgba;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment