2019-03-28 03:59:54 +00:00
|
|
|
#version 300 es
|
|
|
|
|
|
|
|
in highp vec2 uv;
|
|
|
|
out highp vec4 color;
|
|
|
|
|
|
|
|
uniform sampler2D sampler1;
|
2019-04-19 01:23:51 +00:00
|
|
|
|
|
|
|
uniform int nearest;
|
|
|
|
uniform highp vec2 size;
|
2021-01-15 01:40:59 +00:00
|
|
|
uniform int rotate;
|
2019-04-19 01:23:51 +00:00
|
|
|
|
|
|
|
uniform int nv;
|
2019-03-28 13:15:14 +00:00
|
|
|
uniform highp float nvGain;
|
2020-11-08 19:59:54 +00:00
|
|
|
uniform int cbMode;
|
2019-03-28 03:59:54 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2021-01-15 01:40:59 +00:00
|
|
|
highp vec2 ruv;
|
2021-01-18 03:42:57 +00:00
|
|
|
if (rotate == 0) // 0
|
2021-01-15 01:40:59 +00:00
|
|
|
{
|
|
|
|
ruv = uv;
|
|
|
|
}
|
2021-01-18 03:42:57 +00:00
|
|
|
else if (rotate == 1) // 90
|
|
|
|
{
|
|
|
|
ruv.x = uv.y;
|
|
|
|
ruv.y = -uv.x + 1.0f;
|
|
|
|
}
|
|
|
|
else if (rotate == 2) // 180
|
2021-01-15 01:40:59 +00:00
|
|
|
{
|
|
|
|
ruv.x = -uv.x + 1.0f;
|
|
|
|
ruv.y = -uv.y + 1.0f;
|
|
|
|
}
|
2021-01-18 03:42:57 +00:00
|
|
|
else if (rotate == 3) // 270
|
2021-01-15 01:40:59 +00:00
|
|
|
{
|
|
|
|
ruv.x = -uv.y + 1.0f;
|
|
|
|
ruv.y = uv.x;
|
|
|
|
}
|
|
|
|
|
2019-04-19 01:23:51 +00:00
|
|
|
if(nearest == 1)
|
2021-01-15 01:40:59 +00:00
|
|
|
color = texture(sampler1, ruv);
|
2019-04-19 01:23:51 +00:00
|
|
|
else
|
2021-01-15 01:40:59 +00:00
|
|
|
color = texelFetch(sampler1, ivec2(ruv * size), 0);
|
2019-03-30 13:08:52 +00:00
|
|
|
|
2020-11-08 19:59:54 +00:00
|
|
|
if (cbMode > 0)
|
|
|
|
{
|
|
|
|
highp float L = (17.8824000 * color.r) + (43.516100 * color.g) + (4.11935 * color.b);
|
|
|
|
highp float M = (03.4556500 * color.r) + (27.155400 * color.g) + (3.86714 * color.b);
|
|
|
|
highp float S = (00.0299566 * color.r) + (00.184309 * color.g) + (1.46709 * color.b);
|
|
|
|
highp float l, m, s;
|
|
|
|
|
|
|
|
if (cbMode == 1) // Protanope
|
|
|
|
{
|
|
|
|
l = 0.0f * L + 2.02344f * M + -2.52581f * S;
|
|
|
|
m = 0.0f * L + 1.0f * M + 0.0f * S;
|
|
|
|
s = 0.0f * L + 0.0f * M + 1.0f * S;
|
|
|
|
}
|
|
|
|
else if (cbMode == 2) // Deuteranope
|
|
|
|
{
|
|
|
|
l = 1.000000 * L + 0.0f * M + 0.00000 * S;
|
|
|
|
m = 0.494207 * L + 0.0f * M + 1.24827 * S;
|
|
|
|
s = 0.000000 * L + 0.0f * M + 1.00000 * S;
|
|
|
|
}
|
|
|
|
else if (cbMode == 3) // Tritanope
|
|
|
|
{
|
|
|
|
l = 1.000000 * L + 0.000000 * M + 0.0 * S;
|
|
|
|
m = 0.000000 * L + 1.000000 * M + 0.0 * S;
|
|
|
|
s = -0.395913 * L + 0.801109 * M + 0.0 * S;
|
|
|
|
}
|
|
|
|
|
|
|
|
highp vec4 error;
|
|
|
|
error.r = ( 0.080944447900 * l) + (-0.13050440900 * m) + ( 0.116721066 * s);
|
|
|
|
error.g = (-0.010248533500 * l) + ( 0.05401932660 * m) + (-0.113614708 * s);
|
|
|
|
error.b = (-0.000365296938 * l) + (-0.00412161469 * m) + ( 0.693511405 * s);
|
|
|
|
error.a = 0.0;
|
|
|
|
|
|
|
|
error = color - error;
|
|
|
|
color.g += (error.r * 0.7) + (error.g * 1.0);
|
|
|
|
color.b += (error.r * 0.7) + (error.b * 1.0);
|
|
|
|
}
|
|
|
|
|
2019-03-28 13:15:14 +00:00
|
|
|
if (nv == 1)
|
2019-03-30 13:08:52 +00:00
|
|
|
{
|
|
|
|
highp float lumi = 1.0 - (0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b);
|
|
|
|
color *= 1.0 + lumi;
|
2019-03-28 13:15:14 +00:00
|
|
|
color *= nvGain;
|
2019-03-30 13:08:52 +00:00
|
|
|
}
|
2019-03-28 03:59:54 +00:00
|
|
|
}
|