John Stiles | 2b788b1 | 2020-09-21 17:01:22 -0400 | [diff] [blame] | 1 | #version 400 |
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 2 | out vec4 sk_FragColor; |
John Stiles | 9b9415e | 2020-11-23 14:48:06 -0500 | [diff] [blame] | 3 | vec3 _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 Osman | c021360 | 2020-10-06 14:43:32 -0400 | [diff] [blame] | 6 | in vec4 src; |
| 7 | in vec4 dst; |
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 8 | void main() { |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 9 | vec4 _0_blend_hue; |
John Stiles | 35fee4c | 2020-12-16 18:25:14 +0000 | [diff] [blame] | 10 | float _1_alpha = dst.w * src.w; |
| 11 | vec3 _2_sda = src.xyz * dst.w; |
| 12 | vec3 _3_dsa = dst.xyz * src.w; |
John Stiles | 345d721 | 2020-12-15 18:06:29 -0500 | [diff] [blame] | 13 | vec3 _4_blend_set_color_saturation; |
John Stiles | 6f31e27 | 2020-12-16 13:30:54 -0500 | [diff] [blame] | 14 | 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 Stiles | 6f31e27 | 2020-12-16 13:30:54 -0500 | [diff] [blame] | 16 | float _6_sat = _5_blend_color_saturation; |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 17 | |
| 18 | if (_2_sda.x <= _2_sda.y) { |
| 19 | if (_2_sda.y <= _2_sda.z) { |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 20 | _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda, _6_sat); |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 21 | } else if (_2_sda.x <= _2_sda.z) { |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 22 | _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.xzy, _6_sat).xzy; |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 23 | } else { |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 24 | _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.zxy, _6_sat).yzx; |
Brian Osman | 2e25ff4 | 2020-10-15 10:32:04 -0400 | [diff] [blame] | 25 | } |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 26 | } else if (_2_sda.x <= _2_sda.z) { |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 27 | _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.yxz, _6_sat).yxz; |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 28 | } else if (_2_sda.y <= _2_sda.z) { |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 29 | _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.yzx, _6_sat).zxy; |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 30 | } else { |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 31 | _4_blend_set_color_saturation = _blend_set_color_saturation_helper(_2_sda.zyx, _6_sat).zyx; |
John Stiles | bc0c29e | 2020-09-28 13:13:40 -0400 | [diff] [blame] | 32 | } |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 33 | vec3 _7_blend_set_color_luminance; |
John Stiles | 6f31e27 | 2020-12-16 13:30:54 -0500 | [diff] [blame] | 34 | float _8_blend_color_luminance; |
| 35 | _8_blend_color_luminance = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_dsa); |
John Stiles | 6f31e27 | 2020-12-16 13:30:54 -0500 | [diff] [blame] | 36 | float _9_lum = _8_blend_color_luminance; |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 37 | |
John Stiles | 6f31e27 | 2020-12-16 13:30:54 -0500 | [diff] [blame] | 38 | float _10_blend_color_luminance; |
| 39 | _10_blend_color_luminance = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _4_blend_set_color_saturation); |
John Stiles | 6f31e27 | 2020-12-16 13:30:54 -0500 | [diff] [blame] | 40 | vec3 _11_result = (_9_lum - _10_blend_color_luminance) + _4_blend_set_color_saturation; |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 41 | |
John Stiles | 35fee4c | 2020-12-16 18:25:14 +0000 | [diff] [blame] | 42 | 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 Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 44 | 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 Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 46 | } |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 47 | _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 Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 48 | _0_blend_hue = vec4((((_7_blend_set_color_luminance + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha); |
John Stiles | d059005 | 2020-12-15 15:21:03 -0500 | [diff] [blame] | 49 | |
| 50 | |
John Stiles | 9e94812 | 2020-12-16 18:24:48 +0000 | [diff] [blame] | 51 | sk_FragColor = _0_blend_hue; |
| 52 | |
John Stiles | 2b788b1 | 2020-09-21 17:01:22 -0400 | [diff] [blame] | 53 | } |