blob: a6a7a22f44e956d3348ecffd61b70de4f8d5b519 [file] [log] [blame]
John Stiles2b788b12020-09-21 17:01:22 -04001#version 400
John Stilesaeae3a52020-09-25 13:35:58 -04002out vec4 sk_FragColor;
John Stiles9b9415e2020-11-23 14:48:06 -05003vec3 _blend_set_color_saturation_helper(vec3 minMidMax, float sat) {
4 return minMidMax.x < minMidMax.z ? vec3(0.0, (sat * (minMidMax.y - minMidMax.x)) / (minMidMax.z - minMidMax.x), sat) : vec3(0.0);
5}
Brian Osmanc0213602020-10-06 14:43:32 -04006in vec4 src;
7in vec4 dst;
John Stilesaeae3a52020-09-25 13:35:58 -04008void main() {
John Stilese8e4aca2020-12-15 17:50:21 -05009 float _1_alpha;
10 vec3 _2_sda;
11 vec3 _3_dsa;
12 _1_alpha = dst.w * src.w;
13 _2_sda = src.xyz * dst.w;
14 _3_dsa = dst.xyz * src.w;
Brian Osman2e25ff42020-10-15 10:32:04 -040015
John Stiles345d7212020-12-15 18:06:29 -050016 vec3 _4_blend_set_color_saturation;
17 float _5_sat;
18 _5_sat = max(max(_3_dsa.x, _3_dsa.y), _3_dsa.z) - min(min(_3_dsa.x, _3_dsa.y), _3_dsa.z);
John Stilesd0590052020-12-15 15:21:03 -050019
20 if (_2_sda.x <= _2_sda.y) {
21 if (_2_sda.y <= _2_sda.z) {
John Stiles345d7212020-12-15 18:06:29 -050022 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda, _5_sat);
John Stilesd0590052020-12-15 15:21:03 -050023 } else if (_2_sda.x <= _2_sda.z) {
John Stiles345d7212020-12-15 18:06:29 -050024 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.xzy, _5_sat).xzy;
John Stilesd0590052020-12-15 15:21:03 -050025 } else {
John Stiles345d7212020-12-15 18:06:29 -050026 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.zxy, _5_sat).yzx;
Brian Osman2e25ff42020-10-15 10:32:04 -040027 }
John Stilesd0590052020-12-15 15:21:03 -050028 } else if (_2_sda.x <= _2_sda.z) {
John Stiles345d7212020-12-15 18:06:29 -050029 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.yxz, _5_sat).yxz;
John Stilesd0590052020-12-15 15:21:03 -050030 } else if (_2_sda.y <= _2_sda.z) {
John Stiles345d7212020-12-15 18:06:29 -050031 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.yzx, _5_sat).zxy;
John Stilesd0590052020-12-15 15:21:03 -050032 } else {
John Stiles345d7212020-12-15 18:06:29 -050033 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.zyx, _5_sat).zyx;
John Stilesbc0c29e2020-09-28 13:13:40 -040034 }
John Stilesd0590052020-12-15 15:21:03 -050035
John Stiles345d7212020-12-15 18:06:29 -050036 float _7_lum;
37 vec3 _8_result;
38 float _9_minComp;
39 float _10_maxComp;
40 _7_lum = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_dsa);
John Stilesd0590052020-12-15 15:21:03 -050041
John Stiles345d7212020-12-15 18:06:29 -050042 _8_result = (_7_lum - dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _4_blend_set_color_saturation)) + _4_blend_set_color_saturation;
John Stilesd0590052020-12-15 15:21:03 -050043
John Stiles345d7212020-12-15 18:06:29 -050044 _9_minComp = min(min(_8_result.x, _8_result.y), _8_result.z);
45 _10_maxComp = max(max(_8_result.x, _8_result.y), _8_result.z);
46 if (_9_minComp < 0.0 && _7_lum != _9_minComp) {
47 _8_result = _7_lum + ((_8_result - _7_lum) * _7_lum) / (_7_lum - _9_minComp);
John Stilesd0590052020-12-15 15:21:03 -050048 }
John Stilesd0590052020-12-15 15:21:03 -050049
John Stiles345d7212020-12-15 18:06:29 -050050 sk_FragColor = vec4(((((_10_maxComp > _1_alpha && _10_maxComp != _7_lum ? _7_lum + ((_8_result - _7_lum) * (_1_alpha - _7_lum)) / (_10_maxComp - _7_lum) : _8_result) + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha);
John Stilesd0590052020-12-15 15:21:03 -050051
52
53
John Stiles2b788b12020-09-21 17:01:22 -040054}