Last active
January 2, 2016 01:09
-
-
Save McZonk/8228152 to your computer and use it in GitHub Desktop.
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
// vertex shader | |
attribute vec4 a_color; | |
attribute vec4 a_position; | |
attribute vec2 a_tex_coord; | |
varying mediump vec2 v_tex_coord; | |
varying lowp vec4 v_color_mix; | |
void main() { | |
v_color_mix = a_color; | |
v_tex_coord = a_tex_coord; | |
gl_Position = a_position; | |
} | |
// fragment shader | |
uniform lowp sampler2D u_texture_luma; | |
uniform lowp sampler2D u_texture_chroma; | |
uniform lowp vec3 u_ycbcr_matrix[4]; | |
varying mediump vec2 v_tex_coord; | |
varying lowp vec4 v_color_mix; | |
void main() { | |
lowp vec3 color; | |
lowp vec3 ycbcr = vec3( | |
texture2D(u_texture_luma, v_tex_coord).r, | |
texture2D(u_texture_chroma, v_tex_coord).ba | |
); | |
color.r = dot(ycbcr, u_ycbcr_matrix[0]); | |
color.g = dot(ycbcr, u_ycbcr_matrix[1]); | |
color.b = dot(ycbcr, u_ycbcr_matrix[2]); | |
color += u_ycbcr_matrix[3]; | |
gl_FragColor = vec4(color, 1.0) * v_color_mix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment