Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created June 17, 2013 08:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save roxlu/5795504 to your computer and use it in GitHub Desktop.
Save roxlu/5795504 to your computer and use it in GitHub Desktop.
GL 3.0, UYVY422 shader using GL_RGB_422_APPLE as internalFormat, GL_UNSIGNED_SHORT_8_8_APPLE as format
static const char* YUYV_VS = ""
"#version 150\n"
"uniform mat4 u_pm;"
"uniform mat4 u_mm;"
"in vec4 a_pos;"
"in vec2 a_tex;"
"out vec2 v_tex;"
"void main() {"
" gl_Position = u_pm * u_mm * a_pos; "
" v_tex = a_tex;"
"}"
"";
static const char* YUYV_FS = ""
"#version 150\n"
"uniform sampler2D u_tex;"
"out vec4 outcol;"
"in vec2 v_tex;"
"const vec3 R_cf = vec3(1.164383, 0.000000, 1.596027);"
"const vec3 G_cf = vec3(1.164383, -0.391762, -0.812968);"
"const vec3 B_cf = vec3(1.164383, 2.017232, 0.000000);"
"const vec3 offset = vec3(-0.0625, -0.5, -0.5);"
"void main() {"
" vec3 tc = texture( u_tex, v_tex ).rgb;"
" vec3 yuv = vec3(tc.g, tc.b, tc.r);"
" yuv += offset;"
" outcol.r = dot(yuv, R_cf);"
" outcol.g = dot(yuv, G_cf);"
" outcol.b = dot(yuv, B_cf);"
" outcol.a = 1.0;"
"}"
"";
@debugly
Copy link

debugly commented Jan 20, 2022

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment