Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // fragment.glsl
- #version 400
- uniform usampler2D 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
- float y = (float(texture(yuvTexture, vec2(texcoord.s, texcoord.t * YHeight)).r) - 64) / 876.0;
- float u = (float(texture(yuvTexture, vec2(texcoord.s / 2, UOffset + texcoord.t * UHeight)).r) - 512) / 896.0;
- float v = (float(texture(yuvTexture, vec2(texcoord.s / 2, VOffset + texcoord.t * VHeight)).r) - 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