2020-11-25 16:47:10 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Intel Corporation
|
2021-02-08 18:11:29 +03:00
|
|
|
* Copyright 2015,2019,2021 Collabora, Ltd.
|
2020-11-25 16:47:10 +03:00
|
|
|
* Copyright 2016 NVIDIA Corporation
|
2021-09-22 20:59:40 +03:00
|
|
|
* Copyright 2021 Advanced Micro Devices, Inc.
|
2020-11-25 16:47:10 +03:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* GLSL version 1.00 ES, defined in gl-shaders.c */
|
|
|
|
|
2021-03-15 15:02:50 +03:00
|
|
|
/* For annotating shader compile-time constant arguments */
|
|
|
|
#define compile_const const
|
|
|
|
|
2020-11-25 16:47:10 +03:00
|
|
|
/*
|
2019-04-18 19:15:48 +03:00
|
|
|
* Enumeration of shader variants, must match enum gl_shader_texture_variant.
|
2020-11-25 16:47:10 +03:00
|
|
|
*/
|
|
|
|
#define SHADER_VARIANT_RGBX 1
|
|
|
|
#define SHADER_VARIANT_RGBA 2
|
|
|
|
#define SHADER_VARIANT_Y_U_V 3
|
|
|
|
#define SHADER_VARIANT_Y_UV 4
|
|
|
|
#define SHADER_VARIANT_Y_XUXV 5
|
|
|
|
#define SHADER_VARIANT_XYUV 6
|
|
|
|
#define SHADER_VARIANT_SOLID 7
|
|
|
|
#define SHADER_VARIANT_EXTERNAL 8
|
|
|
|
|
2021-03-22 17:17:28 +03:00
|
|
|
/* enum gl_shader_color_curve */
|
|
|
|
#define SHADER_COLOR_CURVE_IDENTITY 0
|
|
|
|
#define SHADER_COLOR_CURVE_LUT_3x1D 1
|
|
|
|
|
2021-09-22 20:59:40 +03:00
|
|
|
/* enum gl_shader_color_mapping */
|
|
|
|
#define SHADER_COLOR_MAPPING_IDENTITY 0
|
|
|
|
#define SHADER_COLOR_MAPPING_3DLUT 1
|
2022-06-25 22:48:49 +03:00
|
|
|
#define SHADER_COLOR_MAPPING_MATRIX 2
|
2021-09-22 20:59:40 +03:00
|
|
|
|
2020-11-25 16:47:10 +03:00
|
|
|
#if DEF_VARIANT == SHADER_VARIANT_EXTERNAL
|
|
|
|
#extension GL_OES_EGL_image_external : require
|
|
|
|
#endif
|
|
|
|
|
2021-09-22 20:59:40 +03:00
|
|
|
#if DEF_COLOR_MAPPING == SHADER_COLOR_MAPPING_3DLUT
|
|
|
|
#extension GL_OES_texture_3D : require
|
|
|
|
#endif
|
|
|
|
|
2021-03-22 17:42:40 +03:00
|
|
|
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
|
|
#define HIGHPRECISION highp
|
|
|
|
#else
|
|
|
|
#define HIGHPRECISION mediump
|
|
|
|
#endif
|
|
|
|
|
|
|
|
precision HIGHPRECISION float;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These undeclared identifiers will be #defined by a runtime generated code
|
|
|
|
* snippet.
|
|
|
|
*/
|
2021-03-15 15:02:50 +03:00
|
|
|
compile_const int c_variant = DEF_VARIANT;
|
2021-03-12 15:06:34 +03:00
|
|
|
compile_const bool c_input_is_premult = DEF_INPUT_IS_PREMULT;
|
2021-03-15 15:02:50 +03:00
|
|
|
compile_const bool c_green_tint = DEF_GREEN_TINT;
|
2021-03-22 17:17:28 +03:00
|
|
|
compile_const int c_color_pre_curve = DEF_COLOR_PRE_CURVE;
|
2021-09-22 20:59:40 +03:00
|
|
|
compile_const int c_color_mapping = DEF_COLOR_MAPPING;
|
2022-06-24 17:48:38 +03:00
|
|
|
compile_const int c_color_post_curve = DEF_COLOR_POST_CURVE;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
2022-06-02 11:24:52 +03:00
|
|
|
compile_const bool c_need_color_pipeline =
|
|
|
|
c_color_pre_curve != SHADER_COLOR_CURVE_IDENTITY ||
|
2022-06-24 17:48:38 +03:00
|
|
|
c_color_mapping != SHADER_COLOR_MAPPING_IDENTITY ||
|
|
|
|
c_color_post_curve != SHADER_COLOR_CURVE_IDENTITY;
|
2022-06-02 11:24:52 +03:00
|
|
|
|
2020-11-25 16:47:10 +03:00
|
|
|
vec4
|
2021-02-08 18:11:29 +03:00
|
|
|
yuva2rgba(vec4 yuva)
|
2020-11-25 16:47:10 +03:00
|
|
|
{
|
|
|
|
vec4 color_out;
|
2021-02-08 18:11:29 +03:00
|
|
|
float Y, su, sv;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
gl-renderer: doc YCbCr-RGB conversion
I have verified that the conversion here follows ITU-R BT.601 except for
the offsets 16/256 and 128/256 which should be 16/255 and 128/255
respectively.
I used to following octave script to verify this:
rf = 0.299;
gf = 0.587;
bf = 0.114;
crdiv = 1.402;
cbdiv = 1.772;
M = [ rf, gf, bf ;
-rf / cbdiv, -gf / cbdiv, (1 - bf) / cbdiv;
(1 - rf) / crdiv, -gf / crdiv, -bf / crdiv ];
YCbCr = [ 'Y'; 'Cb'; 'Cr' ];
RGB = [ 'R'; 'G'; 'B' ];
eq = [ ' '; '='; ' ' ];
l = [ ' [ '; ' [ '; ' [ ' ];
r = [ ' ] '; ' ] '; ' ] ' ];
mat = [
sprintf('%9f %9f %9f', M(1,:));
sprintf('%9f %9f %9f', M(2,:));
sprintf('%9f %9f %9f', M(3,:));
];
[ l YCbCr r eq l mat r l RGB r ]
R = inv(M);
mat = [
sprintf('%9f %9f %9f', R(1,:));
sprintf('%9f %9f %9f', R(2,:));
sprintf('%9f %9f %9f', R(3,:));
];
[ l RGB r eq l mat r l YCbCr r ]
[ R(:,1), R(:,2:3) .* (255/224) ]
The final matrix printed is what the shader uses down to +/- one digit,
so at least 7 correct decimals.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-04 17:35:29 +03:00
|
|
|
/* ITU-R BT.601 & BT.709 quantization (limited range) */
|
|
|
|
|
|
|
|
/* Y = 255/219 * (x - 16/256) */
|
2021-02-08 18:11:29 +03:00
|
|
|
Y = 1.16438356 * (yuva.x - 0.0625);
|
gl-renderer: doc YCbCr-RGB conversion
I have verified that the conversion here follows ITU-R BT.601 except for
the offsets 16/256 and 128/256 which should be 16/255 and 128/255
respectively.
I used to following octave script to verify this:
rf = 0.299;
gf = 0.587;
bf = 0.114;
crdiv = 1.402;
cbdiv = 1.772;
M = [ rf, gf, bf ;
-rf / cbdiv, -gf / cbdiv, (1 - bf) / cbdiv;
(1 - rf) / crdiv, -gf / crdiv, -bf / crdiv ];
YCbCr = [ 'Y'; 'Cb'; 'Cr' ];
RGB = [ 'R'; 'G'; 'B' ];
eq = [ ' '; '='; ' ' ];
l = [ ' [ '; ' [ '; ' [ ' ];
r = [ ' ] '; ' ] '; ' ] ' ];
mat = [
sprintf('%9f %9f %9f', M(1,:));
sprintf('%9f %9f %9f', M(2,:));
sprintf('%9f %9f %9f', M(3,:));
];
[ l YCbCr r eq l mat r l RGB r ]
R = inv(M);
mat = [
sprintf('%9f %9f %9f', R(1,:));
sprintf('%9f %9f %9f', R(2,:));
sprintf('%9f %9f %9f', R(3,:));
];
[ l RGB r eq l mat r l YCbCr r ]
[ R(:,1), R(:,2:3) .* (255/224) ]
The final matrix printed is what the shader uses down to +/- one digit,
so at least 7 correct decimals.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-04 17:35:29 +03:00
|
|
|
|
|
|
|
/* Remove offset 128/256, but the 255/224 multiplier comes later */
|
2021-02-08 18:11:29 +03:00
|
|
|
su = yuva.y - 0.5;
|
|
|
|
sv = yuva.z - 0.5;
|
2021-02-08 17:54:12 +03:00
|
|
|
|
gl-renderer: doc YCbCr-RGB conversion
I have verified that the conversion here follows ITU-R BT.601 except for
the offsets 16/256 and 128/256 which should be 16/255 and 128/255
respectively.
I used to following octave script to verify this:
rf = 0.299;
gf = 0.587;
bf = 0.114;
crdiv = 1.402;
cbdiv = 1.772;
M = [ rf, gf, bf ;
-rf / cbdiv, -gf / cbdiv, (1 - bf) / cbdiv;
(1 - rf) / crdiv, -gf / crdiv, -bf / crdiv ];
YCbCr = [ 'Y'; 'Cb'; 'Cr' ];
RGB = [ 'R'; 'G'; 'B' ];
eq = [ ' '; '='; ' ' ];
l = [ ' [ '; ' [ '; ' [ ' ];
r = [ ' ] '; ' ] '; ' ] ' ];
mat = [
sprintf('%9f %9f %9f', M(1,:));
sprintf('%9f %9f %9f', M(2,:));
sprintf('%9f %9f %9f', M(3,:));
];
[ l YCbCr r eq l mat r l RGB r ]
R = inv(M);
mat = [
sprintf('%9f %9f %9f', R(1,:));
sprintf('%9f %9f %9f', R(2,:));
sprintf('%9f %9f %9f', R(3,:));
];
[ l RGB r eq l mat r l YCbCr r ]
[ R(:,1), R(:,2:3) .* (255/224) ]
The final matrix printed is what the shader uses down to +/- one digit,
so at least 7 correct decimals.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-04 17:35:29 +03:00
|
|
|
/*
|
|
|
|
* ITU-R BT.601 encoding coefficients (inverse), with the
|
|
|
|
* 255/224 limited range multiplier already included in the
|
|
|
|
* factors for su (Cb) and sv (Cr).
|
|
|
|
*/
|
2021-02-08 18:11:29 +03:00
|
|
|
color_out.r = Y + 1.59602678 * sv;
|
|
|
|
color_out.g = Y - 0.39176229 * su - 0.81296764 * sv;
|
|
|
|
color_out.b = Y + 2.01723214 * su;
|
|
|
|
|
|
|
|
color_out.a = yuva.w;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
|
|
|
return color_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEF_VARIANT == SHADER_VARIANT_EXTERNAL
|
|
|
|
uniform samplerExternalOES tex;
|
|
|
|
#else
|
|
|
|
uniform sampler2D tex;
|
|
|
|
#endif
|
|
|
|
|
2023-02-03 00:34:17 +03:00
|
|
|
varying HIGHPRECISION vec2 v_texcoord;
|
2020-11-25 16:47:10 +03:00
|
|
|
uniform sampler2D tex1;
|
|
|
|
uniform sampler2D tex2;
|
2022-06-03 13:57:05 +03:00
|
|
|
uniform float view_alpha;
|
2021-02-02 17:52:35 +03:00
|
|
|
uniform vec4 unicolor;
|
2021-03-22 17:17:28 +03:00
|
|
|
uniform HIGHPRECISION sampler2D color_pre_curve_lut_2d;
|
|
|
|
uniform HIGHPRECISION vec2 color_pre_curve_lut_scale_offset;
|
2022-06-24 17:48:38 +03:00
|
|
|
uniform HIGHPRECISION sampler2D color_post_curve_lut_2d;
|
|
|
|
uniform HIGHPRECISION vec2 color_post_curve_lut_scale_offset;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
2021-09-22 20:59:40 +03:00
|
|
|
#if DEF_COLOR_MAPPING == SHADER_COLOR_MAPPING_3DLUT
|
|
|
|
uniform HIGHPRECISION sampler3D color_mapping_lut_3d;
|
|
|
|
uniform HIGHPRECISION vec2 color_mapping_lut_scale_offset;
|
|
|
|
#endif
|
2022-06-25 22:48:49 +03:00
|
|
|
uniform HIGHPRECISION mat3 color_mapping_matrix;
|
2021-09-22 20:59:40 +03:00
|
|
|
|
2021-02-08 18:30:51 +03:00
|
|
|
vec4
|
|
|
|
sample_input_texture()
|
2020-11-25 16:47:10 +03:00
|
|
|
{
|
2021-02-09 14:27:36 +03:00
|
|
|
vec4 yuva = vec4(0.0, 0.0, 0.0, 1.0);
|
2020-11-25 16:47:10 +03:00
|
|
|
|
2021-02-08 18:30:51 +03:00
|
|
|
/* Producing RGBA directly */
|
|
|
|
|
|
|
|
if (c_variant == SHADER_VARIANT_SOLID)
|
2021-02-09 14:27:36 +03:00
|
|
|
return unicolor;
|
2021-02-08 18:30:51 +03:00
|
|
|
|
2020-11-25 16:47:10 +03:00
|
|
|
if (c_variant == SHADER_VARIANT_RGBA ||
|
|
|
|
c_variant == SHADER_VARIANT_EXTERNAL) {
|
2021-02-09 14:27:36 +03:00
|
|
|
return texture2D(tex, v_texcoord);
|
2021-02-08 18:30:51 +03:00
|
|
|
}
|
2020-11-25 16:47:10 +03:00
|
|
|
|
2021-02-08 18:30:51 +03:00
|
|
|
if (c_variant == SHADER_VARIANT_RGBX)
|
2021-02-09 14:27:36 +03:00
|
|
|
return vec4(texture2D(tex, v_texcoord).rgb, 1.0);
|
2020-11-25 16:47:10 +03:00
|
|
|
|
2021-02-08 18:30:51 +03:00
|
|
|
/* Requires conversion to RGBA */
|
|
|
|
|
|
|
|
if (c_variant == SHADER_VARIANT_Y_U_V) {
|
2021-02-08 18:11:29 +03:00
|
|
|
yuva.x = texture2D(tex, v_texcoord).x;
|
|
|
|
yuva.y = texture2D(tex1, v_texcoord).x;
|
|
|
|
yuva.z = texture2D(tex2, v_texcoord).x;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
|
|
|
} else if (c_variant == SHADER_VARIANT_Y_UV) {
|
2021-02-08 18:11:29 +03:00
|
|
|
yuva.x = texture2D(tex, v_texcoord).x;
|
2021-02-08 18:18:25 +03:00
|
|
|
yuva.yz = texture2D(tex1, v_texcoord).rg;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
|
|
|
} else if (c_variant == SHADER_VARIANT_Y_XUXV) {
|
2021-02-08 18:11:29 +03:00
|
|
|
yuva.x = texture2D(tex, v_texcoord).x;
|
2021-02-08 18:18:25 +03:00
|
|
|
yuva.yz = texture2D(tex1, v_texcoord).ga;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
|
|
|
} else if (c_variant == SHADER_VARIANT_XYUV) {
|
2021-02-08 18:18:25 +03:00
|
|
|
yuva.xyz = texture2D(tex, v_texcoord).bgr;
|
2020-11-25 16:47:10 +03:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/* Never reached, bad variant value. */
|
2021-02-08 18:30:51 +03:00
|
|
|
return vec4(1.0, 0.3, 1.0, 1.0);
|
2020-11-25 16:47:10 +03:00
|
|
|
}
|
|
|
|
|
2021-02-08 18:30:51 +03:00
|
|
|
return yuva2rgba(yuva);
|
|
|
|
}
|
|
|
|
|
2021-03-22 17:17:28 +03:00
|
|
|
/*
|
|
|
|
* Texture coordinates go from 0.0 to 1.0 corresponding to texture edges.
|
|
|
|
* When we do LUT look-ups with linear filtering, the correct range to sample
|
|
|
|
* from is not from edge to edge, but center of first texel to center of last
|
|
|
|
* texel. This follows because with LUTs, you have the exact end points given,
|
|
|
|
* you never extrapolate but only interpolate.
|
|
|
|
* The scale and offset are precomputed to achieve this mapping.
|
|
|
|
*/
|
|
|
|
float
|
|
|
|
lut_texcoord(float x, vec2 scale_offset)
|
|
|
|
{
|
|
|
|
return x * scale_offset.s + scale_offset.t;
|
|
|
|
}
|
|
|
|
|
2021-09-22 20:59:40 +03:00
|
|
|
vec3
|
|
|
|
lut_texcoord(vec3 pos, vec2 scale_offset)
|
|
|
|
{
|
|
|
|
return pos * scale_offset.s + scale_offset.t;
|
|
|
|
}
|
|
|
|
|
2021-03-22 17:17:28 +03:00
|
|
|
/*
|
|
|
|
* Sample a 1D LUT which is a single row of a 2D texture. The 2D texture has
|
|
|
|
* four rows so that the centers of texels have precise y-coordinates.
|
|
|
|
*/
|
|
|
|
float
|
|
|
|
sample_color_pre_curve_lut_2d(float x, compile_const int row)
|
|
|
|
{
|
|
|
|
float tx = lut_texcoord(x, color_pre_curve_lut_scale_offset);
|
|
|
|
|
|
|
|
return texture2D(color_pre_curve_lut_2d,
|
|
|
|
vec2(tx, (float(row) + 0.5) / 4.0)).x;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3
|
|
|
|
color_pre_curve(vec3 color)
|
|
|
|
{
|
|
|
|
vec3 ret;
|
|
|
|
|
|
|
|
if (c_color_pre_curve == SHADER_COLOR_CURVE_IDENTITY) {
|
|
|
|
return color;
|
|
|
|
} else if (c_color_pre_curve == SHADER_COLOR_CURVE_LUT_3x1D) {
|
|
|
|
ret.r = sample_color_pre_curve_lut_2d(color.r, 0);
|
|
|
|
ret.g = sample_color_pre_curve_lut_2d(color.g, 1);
|
|
|
|
ret.b = sample_color_pre_curve_lut_2d(color.b, 2);
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
/* Never reached, bad c_color_pre_curve. */
|
|
|
|
return vec3(1.0, 0.3, 1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-22 20:59:40 +03:00
|
|
|
vec3
|
|
|
|
sample_color_mapping_lut_3d(vec3 color)
|
|
|
|
{
|
|
|
|
vec3 pos, ret = vec3(0.0, 0.0, 0.0);
|
|
|
|
#if DEF_COLOR_MAPPING == SHADER_COLOR_MAPPING_3DLUT
|
|
|
|
pos = lut_texcoord(color, color_mapping_lut_scale_offset);
|
|
|
|
ret = texture3D(color_mapping_lut_3d, pos).rgb;
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3
|
|
|
|
color_mapping(vec3 color)
|
|
|
|
{
|
|
|
|
if (c_color_mapping == SHADER_COLOR_MAPPING_IDENTITY)
|
|
|
|
return color;
|
|
|
|
else if (c_color_mapping == SHADER_COLOR_MAPPING_3DLUT)
|
|
|
|
return sample_color_mapping_lut_3d(color);
|
2022-06-25 22:48:49 +03:00
|
|
|
else if (c_color_mapping == SHADER_COLOR_MAPPING_MATRIX)
|
|
|
|
return color_mapping_matrix * color.rgb;
|
2021-09-22 20:59:40 +03:00
|
|
|
else /* Never reached, bad c_color_mapping. */
|
|
|
|
return vec3(1.0, 0.3, 1.0);
|
|
|
|
}
|
|
|
|
|
2022-06-24 17:48:38 +03:00
|
|
|
float
|
|
|
|
sample_color_post_curve_lut_2d(float x, compile_const int row)
|
|
|
|
{
|
|
|
|
float tx = lut_texcoord(x, color_post_curve_lut_scale_offset);
|
|
|
|
|
|
|
|
return texture2D(color_post_curve_lut_2d,
|
|
|
|
vec2(tx, (float(row) + 0.5) / 4.0)).x;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3
|
|
|
|
color_post_curve(vec3 color)
|
|
|
|
{
|
|
|
|
vec3 ret;
|
|
|
|
|
|
|
|
if (c_color_post_curve == SHADER_COLOR_CURVE_IDENTITY) {
|
|
|
|
return color;
|
|
|
|
} else if (c_color_post_curve == SHADER_COLOR_CURVE_LUT_3x1D) {
|
|
|
|
ret.r = sample_color_post_curve_lut_2d(color.r, 0);
|
|
|
|
ret.g = sample_color_post_curve_lut_2d(color.g, 1);
|
|
|
|
ret.b = sample_color_post_curve_lut_2d(color.b, 2);
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
/* Never reached, bad c_color_post_curve. */
|
|
|
|
return vec3(1.0, 0.3, 1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-22 17:17:28 +03:00
|
|
|
vec4
|
|
|
|
color_pipeline(vec4 color)
|
|
|
|
{
|
2022-06-03 14:01:50 +03:00
|
|
|
/* Ensure straight alpha */
|
|
|
|
if (c_input_is_premult) {
|
|
|
|
if (color.a == 0.0)
|
|
|
|
color.rgb = vec3(0, 0, 0);
|
|
|
|
else
|
|
|
|
color.rgb *= 1.0 / color.a;
|
|
|
|
}
|
|
|
|
|
2021-03-22 17:17:28 +03:00
|
|
|
color.rgb = color_pre_curve(color.rgb);
|
2021-09-22 20:59:40 +03:00
|
|
|
color.rgb = color_mapping(color.rgb);
|
2022-06-24 17:48:38 +03:00
|
|
|
color.rgb = color_post_curve(color.rgb);
|
2021-03-22 17:17:28 +03:00
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2021-02-08 18:30:51 +03:00
|
|
|
void
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
vec4 color;
|
|
|
|
|
2021-03-12 15:06:34 +03:00
|
|
|
/* Electrical (non-linear) RGBA values, may be premult or not */
|
2021-02-08 18:30:51 +03:00
|
|
|
color = sample_input_texture();
|
|
|
|
|
2022-06-03 14:15:01 +03:00
|
|
|
if (c_need_color_pipeline)
|
2022-06-03 14:01:50 +03:00
|
|
|
color = color_pipeline(color); /* Produces straight alpha */
|
2021-03-22 17:17:28 +03:00
|
|
|
|
2022-06-03 14:15:01 +03:00
|
|
|
/* Ensure pre-multiplied for blending */
|
|
|
|
if (!c_input_is_premult || c_need_color_pipeline)
|
2022-06-02 11:24:52 +03:00
|
|
|
color.rgb *= color.a;
|
2022-06-03 14:15:01 +03:00
|
|
|
|
|
|
|
color *= view_alpha;
|
2021-02-09 14:27:36 +03:00
|
|
|
|
2020-11-30 14:46:45 +03:00
|
|
|
if (c_green_tint)
|
2021-02-08 18:30:51 +03:00
|
|
|
color = vec4(0.0, 0.3, 0.0, 0.2) + color * 0.8;
|
|
|
|
|
|
|
|
gl_FragColor = color;
|
2020-11-25 16:47:10 +03:00
|
|
|
}
|