Skip to content

Instantly share code, notes, and snippets.

@EgorBo
Created July 26, 2017 11:38
Show Gist options
  • Save EgorBo/27b3b039d2c67fd41d9711ab665537a7 to your computer and use it in GitHub Desktop.
Save EgorBo/27b3b039d2c67fd41d9711ab665537a7 to your computer and use it in GitHub Desktop.
shader.glsl
#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
#include "ScreenPos.glsl"
varying highp vec2 vScreenPos;
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vScreenPos = GetScreenPosPreDiv(gl_Position);
}
void PS()
{
//temp workaround - flip vertically:
vec2 vTexCoord = vec2(vScreenPos.x, 1.0 - vScreenPos.y);
mat4 ycbcrToRGBTransform = mat4(
vec4(+1.0000, +1.0000, +1.0000, +0.0000),
vec4(+0.0000, -0.3441, +1.7720, +0.0000),
vec4(+1.4020, -0.7141, +0.0000, +0.0000),
vec4(-0.7010, +0.5291, -0.8860, +1.0000));
vec4 ycbcr = vec4(texture2D(sDiffMap, vTexCoord).r,
texture2D(sNormalMap, vTexCoord).ra, 1.0);
gl_FragColor = ycbcrToRGBTransform * ycbcr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment