Created
May 18, 2016 04:46
-
-
Save wangchauyan/b0596103e9b18ac3eec946feaa185392 to your computer and use it in GitHub Desktop.
Convert YUV to RGB
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
const char fragmentShader_yuv420p[] = | |
{ | |
"precision mediump float;\n" | |
"uniform sampler2D Ytex;\n" | |
"uniform sampler2D Utex,Vtex;\n" | |
"varying vec2 vTextureCoord;\n" | |
"void main(void) {\n" | |
" float nx,ny,r,g,b,y,u,v;\n" | |
" mediump vec4 txl,ux,vx;" | |
" nx=vTextureCoord[0];\n" | |
" ny=vTextureCoord[1];\n" | |
" y=texture2D(Ytex,vec2(nx,ny)).r;\n" | |
" u=texture2D(Utex,vec2(nx,ny)).r;\n" | |
" v=texture2D(Vtex,vec2(nx,ny)).r;\n" | |
" y=1.1643*(y-0.0625);\n" | |
" u=u-0.5;\n" | |
" v=v-0.5;\n" | |
" r=y+1.5958*v;\n" | |
" g=y-0.39173*u-0.81290*v;\n" | |
" b=y+2.017*u;\n" | |
" gl_FragColor=vec4(r,g,b,1.0);\n" | |
"}\n" | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment