RBG/YUV/HSV
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" };
https://bbs.csdn.net/topics/390408474?list=lz
https://blog.csdn.net/qq_28299311/article/details/105101378
ec3 rgb2hsb( in vec3 c ){ vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz),vec4(c.gb, K.xy),step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r),vec4(c.r, p.yzx),step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)),d / (q.x + e),q.x); }