Skip to content

Instantly share code, notes, and snippets.

@x-labz
Last active February 2, 2022 13:51
Show Gist options
  • Save x-labz/1a4d641e7e368fde93cb5993967d3d47 to your computer and use it in GitHub Desktop.
Save x-labz/1a4d641e7e368fde93cb5993967d3d47 to your computer and use it in GitHub Desktop.
Fragment shader
precision highp float;
uniform sampler2D u_image;
uniform sampler2D u_image_frame;
uniform vec2 u_resolution;
varying vec2 v_texCoord;
void main() {
float x_offset = mod( gl_FragCoord.y ,2.0 ) < 1.0 ? 0.5 : 0.0 ;
vec4 y4 = texture2D(u_image_frame, vec2 ( v_texCoord.x / 1.0 , v_texCoord.y / 1.5 ) ) ;
vec4 u4 = (texture2D(u_image_frame, vec2 ( x_offset + v_texCoord.x / 2.0 ,2.0/3.0 + v_texCoord.y / 6.0 ) ) -0.50 ) * 2.0 ;
vec4 v4 = (texture2D(u_image_frame, vec2 ( x_offset + v_texCoord.x / 2.0 , 5.0/6.0 + v_texCoord.y / 6.0 ) ) -0.50 ) * 2.0 ;
float y = y4[0] ;
float u = u4[0] ;
float v = v4[0] ;
float R = clamp(y + 1.13 * v, 0.0, 1.0) ;
float G = clamp(y - 0.39 * u - 0.58 * v, 0.0, 1.0) ;
float B = clamp(y + 2.03 * u, 0.0, 1.0) ;
vec4 video_pixel = vec4( vec3(R,G,B), 1.0) ;
gl_FragColor = G > (R+B) ? texture2D(u_image, v_texCoord) : video_pixel ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment