ycocg-based colour grading test wip

This commit is contained in:
minjaesong
2022-04-07 17:48:24 +09:00
parent 97633eba46
commit 6238e92f65

View File

@@ -0,0 +1,31 @@
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
mat4 rgb_to_ycocg = mat4(
0.25, 0.5, 0.25, 1.0,
1.0, 0.0, -1.0, 1.0,
-0.5, 1.0, -0.5, 1.0,
0.0, 0.0, 0.0, 1.0
);
mat4 ycocg_to_rgb = mat4(
1.0, 0.5, -0.5, 1.0,
1.0, 0.0, 0.5, 1.0,
1.0, -0.5, -0.5, 1.0,
0.0, 0.0, 0.0, 1.0
);
vec2 boolean = vec2(0.0, 1.0);
void main() {
vec4 incolour = texture2D(u_texture, v_texCoords);
vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1]
gl_FragColor = ycocg_to_rgb * yog;
}