Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // fragment_alt.glsl
- #version 400
- uniform sampler2D yuvTexture;
- in vec4 texcoord;
- out vec4 frag_color;
- const mat3 HDTV = mat3(1.0, 1.0, 1.0,
- 0.0, -0.187, 1.856,
- 1.575, -0.468, 0.0);
- // Constants needed to extract YUV planes from the texture
- const float YHeight = 2.0 / 3.0;
- const float UHeight = 1.0 / 6.0;
- const float VHeight = UHeight;
- const float UOffset = YHeight;
- const float VOffset = UOffset + UHeight;
- void main()
- {
- // Extract the YUV planes from texture
- vec2 yVec = texture(yuvTexture, vec2(texcoord.s, texcoord.t * YHeight)).rg;
- vec2 uVec = texture(yuvTexture, vec2(texcoord.s / 2, UOffset + texcoord.t * UHeight)).rg;
- vec2 vVec = texture(yuvTexture, vec2(texcoord.s / 2, VOffset + texcoord.t * VHeight)).rg;
- float y = ((yVec.g * 32.0 + yVec.r) * 31.0 - 64) / 876.0;
- float u = ((uVec.g * 32.0 + uVec.r) * 31.0 - 512) / 896.0;
- float v = ((vVec.g * 32.0 + vVec.r) * 31.0 - 512) / 896.0;
- frag_color = vec4(HDTV * vec3(y, u, v), 1.0);
- //frag_color = vec4(texcoord.stp, 1.0);
- }
Add Comment
Please, Sign In to add comment