2020-09-21 21:01:22 +00:00
|
|
|
|
2020-09-25 17:35:58 +00:00
|
|
|
out vec4 sk_FragColor;
|
2021-03-15 18:58:57 +00:00
|
|
|
uniform vec4 src;
|
|
|
|
uniform vec4 dst;
|
2022-04-04 23:52:55 +00:00
|
|
|
vec3 blend_set_color_saturation_helper_Qh3h3h(vec3 minMidMax, float sat) {
|
2022-04-06 16:58:16 +00:00
|
|
|
if (minMidMax.x < minMidMax.z) {
|
|
|
|
return vec3(0.0, (sat * (minMidMax.y - minMidMax.x)) / (minMidMax.z - minMidMax.x), sat);
|
|
|
|
} else {
|
|
|
|
return vec3(0.0);
|
|
|
|
}
|
2022-04-04 23:52:55 +00:00
|
|
|
}
|
|
|
|
vec4 blend_hslc_h4h4h4hb(vec4 src, vec4 dst, float flip, bool saturate) {
|
|
|
|
float alpha = dst.w * src.w;
|
|
|
|
vec3 sda = src.xyz * dst.w;
|
|
|
|
vec3 dsa = dst.xyz * src.w;
|
|
|
|
vec3 l = mix(sda, dsa, flip);
|
|
|
|
vec3 r = mix(dsa, sda, flip);
|
|
|
|
if (saturate) {
|
2022-04-05 15:45:07 +00:00
|
|
|
vec3 _2_blend_set_color_saturation;
|
|
|
|
float _3_sat = max(max(r.x, r.y), r.z) - min(min(r.x, r.y), r.z);
|
2022-04-04 23:52:55 +00:00
|
|
|
if (l.x <= l.y) {
|
|
|
|
if (l.y <= l.z) {
|
2022-04-05 15:45:07 +00:00
|
|
|
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l, _3_sat);
|
2022-04-04 23:52:55 +00:00
|
|
|
} else if (l.x <= l.z) {
|
2022-04-05 15:45:07 +00:00
|
|
|
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.xzy, _3_sat).xzy;
|
2022-04-04 23:52:55 +00:00
|
|
|
} else {
|
2022-04-05 15:45:07 +00:00
|
|
|
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.zxy, _3_sat).yzx;
|
2022-04-04 23:52:55 +00:00
|
|
|
}
|
|
|
|
} else if (l.x <= l.z) {
|
2022-04-05 15:45:07 +00:00
|
|
|
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.yxz, _3_sat).yxz;
|
2022-04-04 23:52:55 +00:00
|
|
|
} else if (l.y <= l.z) {
|
2022-04-05 15:45:07 +00:00
|
|
|
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.yzx, _3_sat).zxy;
|
2022-04-04 23:52:55 +00:00
|
|
|
} else {
|
2022-04-05 15:45:07 +00:00
|
|
|
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.zyx, _3_sat).zyx;
|
2022-04-04 23:52:55 +00:00
|
|
|
}
|
2022-04-05 15:45:07 +00:00
|
|
|
l = _2_blend_set_color_saturation;
|
2022-04-04 23:52:55 +00:00
|
|
|
r = dsa;
|
|
|
|
}
|
2022-04-07 02:29:30 +00:00
|
|
|
float _4_lum = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), r);
|
|
|
|
vec3 _5_result = (_4_lum - dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), l)) + l;
|
|
|
|
float _6_minComp = min(min(_5_result.x, _5_result.y), _5_result.z);
|
|
|
|
float _7_maxComp = max(max(_5_result.x, _5_result.y), _5_result.z);
|
|
|
|
if (_6_minComp < 0.0 && _4_lum != _6_minComp) {
|
|
|
|
_5_result = _4_lum + (_5_result - _4_lum) * (_4_lum / (_4_lum - _6_minComp));
|
2021-03-19 13:46:00 +00:00
|
|
|
}
|
2022-04-07 02:29:30 +00:00
|
|
|
if (_7_maxComp > alpha && _7_maxComp != _4_lum) {
|
|
|
|
_5_result = _4_lum + ((_5_result - _4_lum) * (alpha - _4_lum)) / (_7_maxComp - _4_lum);
|
2021-03-19 13:46:00 +00:00
|
|
|
}
|
2022-04-07 02:29:30 +00:00
|
|
|
return vec4((((_5_result + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
2021-03-19 13:46:00 +00:00
|
|
|
}
|
2021-03-15 22:08:38 +00:00
|
|
|
void main() {
|
2022-04-04 23:52:55 +00:00
|
|
|
sk_FragColor = blend_hslc_h4h4h4hb(src, dst, 1.0, false);
|
2020-09-21 21:01:22 +00:00
|
|
|
}
|