blob: de577aaea80d73432fa84787ae9fb1c9a811928d [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 Stiles9e948122020-12-16 18:24:48 +00009 vec4 _0_blend_hue;
John Stiles35fee4c2020-12-16 18:25:14 +000010 float _1_alpha = dst.w * src.w;
11 vec3 _2_sda = src.xyz * dst.w;
12 vec3 _3_dsa = dst.xyz * src.w;
John Stiles345d7212020-12-15 18:06:29 -050013 vec3 _4_blend_set_color_saturation;
John Stiles6f31e272020-12-16 13:30:54 -050014 float _5_blend_color_saturation;
15 _5_blend_color_saturation = max(max(_3_dsa.x, _3_dsa.y), _3_dsa.z) - min(min(_3_dsa.x, _3_dsa.y), _3_dsa.z);
John Stiles6f31e272020-12-16 13:30:54 -050016 float _6_sat = _5_blend_color_saturation;
John Stilesd0590052020-12-15 15:21:03 -050017
18 if (_2_sda.x <= _2_sda.y) {
19 if (_2_sda.y <= _2_sda.z) {
John Stiles9e948122020-12-16 18:24:48 +000020 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda, _6_sat);
John Stilesd0590052020-12-15 15:21:03 -050021 } else if (_2_sda.x <= _2_sda.z) {
John Stiles9e948122020-12-16 18:24:48 +000022 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.xzy, _6_sat).xzy;
John Stilesd0590052020-12-15 15:21:03 -050023 } else {
John Stiles9e948122020-12-16 18:24:48 +000024 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.zxy, _6_sat).yzx;
Brian Osman2e25ff42020-10-15 10:32:04 -040025 }
John Stilesd0590052020-12-15 15:21:03 -050026 } else if (_2_sda.x <= _2_sda.z) {
John Stiles9e948122020-12-16 18:24:48 +000027 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.yxz, _6_sat).yxz;
John Stilesd0590052020-12-15 15:21:03 -050028 } else if (_2_sda.y <= _2_sda.z) {
John Stiles9e948122020-12-16 18:24:48 +000029 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.yzx, _6_sat).zxy;
John Stilesd0590052020-12-15 15:21:03 -050030 } else {
John Stiles9e948122020-12-16 18:24:48 +000031 _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.zyx, _6_sat).zyx;
John Stilesbc0c29e2020-09-28 13:13:40 -040032 }
John Stiles9e948122020-12-16 18:24:48 +000033 vec3 _7_blend_set_color_luminance;
John Stiles6f31e272020-12-16 13:30:54 -050034 float _8_blend_color_luminance;
35 _8_blend_color_luminance = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_dsa);
John Stiles6f31e272020-12-16 13:30:54 -050036 float _9_lum = _8_blend_color_luminance;
John Stilesd0590052020-12-15 15:21:03 -050037
John Stiles6f31e272020-12-16 13:30:54 -050038 float _10_blend_color_luminance;
39 _10_blend_color_luminance = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _4_blend_set_color_saturation);
John Stiles6f31e272020-12-16 13:30:54 -050040 vec3 _11_result = (_9_lum - _10_blend_color_luminance) + _4_blend_set_color_saturation;
John Stiles9e948122020-12-16 18:24:48 +000041
John Stiles35fee4c2020-12-16 18:25:14 +000042 float _12_minComp = min(min(_11_result.x, _11_result.y), _11_result.z);
43 float _13_maxComp = max(max(_11_result.x, _11_result.y), _11_result.z);
John Stiles9e948122020-12-16 18:24:48 +000044 if (_12_minComp < 0.0 && _9_lum != _12_minComp) {
45 _11_result = _9_lum + ((_11_result - _9_lum) * _9_lum) / (_9_lum - _12_minComp);
John Stilesd0590052020-12-15 15:21:03 -050046 }
John Stiles9e948122020-12-16 18:24:48 +000047 _7_blend_set_color_luminance = _13_maxComp > _1_alpha && _13_maxComp != _9_lum ? _9_lum + ((_11_result - _9_lum) * (_1_alpha - _9_lum)) / (_13_maxComp - _9_lum) : _11_result;
John Stiles9e948122020-12-16 18:24:48 +000048 _0_blend_hue = vec4((((_7_blend_set_color_luminance + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha);
John Stilesd0590052020-12-15 15:21:03 -050049
50
John Stiles9e948122020-12-16 18:24:48 +000051 sk_FragColor = _0_blend_hue;
52
John Stiles2b788b12020-09-21 17:01:22 -040053}