vibrancy is applied to the world only, as it should be

This commit is contained in:
minjaesong
2023-09-13 15:09:31 +09:00
parent f34a9db24c
commit 79892f2525
8 changed files with 102 additions and 79 deletions

View File

@@ -41,20 +41,6 @@ const vec4 matrixNormaliser = vec4(0.5 / 256.0);
const vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
const mat4 rgb_to_ycocg = mat4(
0.25, 1.0, -0.5, 0.0,
0.5, 0.0, 1.0, 0.0,
0.25, -1.0, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
const mat4 ycocg_to_rgb = mat4(
1.0, 1.0, 1.0, 0.0,
0.5, 0.0, -0.5, 0.0,
-0.5, 0.5, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
vec4 nearestColour(vec4 inColor) {
return floor(quantVec * inColor) * invQuant;
@@ -65,23 +51,9 @@ vec4 getDitherredDot(vec4 inColor) {
return nearestColour(fma(bayerThreshold, invQuant, inColor));
}
uniform vec4 vibrancy = vec4(1.0);//vec4(1.0, 1.4, 1.2, 1.0);
void main(void) {
// convert input RGB into YCoCg
vec4 incolour = texture(u_texture, v_texCoords);
vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1]
// Do colour-grading magic
vec4 sgn = sign(yog);
vec4 absval = abs(yog);
vec4 raised = pow(absval, boolean.yyyy / vibrancy);
vec4 newColour = sgn * raised;
// Dither the output
vec4 graded = ycocg_to_rgb * newColour;
vec4 selvec = getDitherredDot(graded);
vec4 selvec = getDitherredDot(incolour);
vec4 outcol = fma(selvec, boolean.yyyx, boolean.xxxy); // use quantised RGB but not the A
fragColor = outcol;

View File

@@ -28,37 +28,9 @@ uniform float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0
const vec2 boolean = vec2(0.0, 1.0);
const mat4 rgb_to_ycocg = mat4(
0.25, 1.0, -0.5, 0.0,
0.5, 0.0, 1.0, 0.0,
0.25, -1.0, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
const mat4 ycocg_to_rgb = mat4(
1.0, 1.0, 1.0, 0.0,
0.5, 0.0, -0.5, 0.0,
-0.5, 0.5, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
uniform vec4 vibrancy = vec4(1.0);//vec4(1.0, 1.4, 1.2, 1.0);
out vec4 fragColor;
void main(void) {
// convert input RGB into YCoCg
vec4 incolour = texture(u_texture, v_texCoords);
vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1]
// Do colour-grading magic
vec4 sgn = sign(yog);
vec4 absval = abs(yog);
vec4 raised = pow(absval, boolean.yyyy / vibrancy);
vec4 newColour = sgn * raised;
// Dither the output
vec4 graded = ycocg_to_rgb * newColour;
fragColor = fma(graded, boolean.yyyx, boolean.xxxy); // use quantised RGB but not the A
fragColor = fma(incolour, boolean.yyyx, boolean.xxxy); // use quantised RGB but not the A
}

55
src/shaders/vibrancy.frag Normal file
View File

@@ -0,0 +1,55 @@
#version 400
#ifdef GL_ES
precision mediump float;
#endif
vec4 gammaIn(vec4 col) {
return pow(col, vec4(2.2));
}
vec4 gammaOut(vec4 col) {
return pow(col, vec4(1.0 / 2.2));
}
in vec4 v_color; // unused!
in vec2 v_texCoords;
uniform sampler2D u_texture;
const vec2 boolean = vec2(0.0, 1.0);
const mat4 rgb_to_ycocg = mat4(
0.25, 1.0, -0.5, 0.0,
0.5, 0.0, 1.0, 0.0,
0.25, -1.0, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
const mat4 ycocg_to_rgb = mat4(
1.0, 1.0, 1.0, 0.0,
0.5, 0.0, -0.5, 0.0,
-0.5, 0.5, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
uniform vec4 vibrancy = vec4(1.0);//vec4(1.0, 1.4, 1.2, 1.0);
out vec4 fragColor;
void main(void) {
// convert input RGB into YCoCg
vec4 incolour = texture(u_texture, v_texCoords);
vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1]
// Do colour-grading magic
vec4 sgn = sign(yog);
vec4 absval = abs(yog);
vec4 raised = pow(absval, boolean.yyyy / vibrancy);
vec4 newColour = sgn * raised;
// Dither the output
vec4 graded = ycocg_to_rgb * newColour;
fragColor = fma(graded, boolean.yyyx, boolean.xxxy); // use quantised RGB but not the A
}