Created
November 19, 2017 21:07
-
-
Save dlublin/01de478a2b282715e978a3587a13814d to your computer and use it in GitHub Desktop.
GLSL fragment shader that performs YCoCg conversion and combines the colour and alpha planes for Hap Q Alpha frames.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform sampler2D cocgsy_src; | |
uniform sampler2D alpha_src; | |
const vec4 offsets = vec4(-0.50196078431373, -0.50196078431373, 0.0, 0.0); | |
void main() | |
{ | |
vec4 CoCgSY = texture2D(cocgsy_src, gl_TexCoord[0].xy); | |
vec4 theAlpha = texture2D(alpha_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, theAlpha.r); | |
gl_FragColor = rgba; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment