2020-09-25 17:35:58 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct Inputs {
|
2020-10-06 18:43:32 +00:00
|
|
|
float4 src;
|
|
|
|
float4 dst;
|
2020-09-25 17:35:58 +00:00
|
|
|
};
|
|
|
|
struct Outputs {
|
|
|
|
float4 sk_FragColor [[color(0)]];
|
|
|
|
};
|
|
|
|
|
2020-10-06 18:43:32 +00:00
|
|
|
|
2020-10-15 14:32:04 +00:00
|
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
|
|
|
Outputs _outputStruct;
|
|
|
|
thread Outputs* _out = &_outputStruct;
|
|
|
|
float4 _0_blend_hue;
|
2020-09-25 17:35:58 +00:00
|
|
|
{
|
2020-10-15 14:32:04 +00:00
|
|
|
float _1_alpha = _in.dst.w * _in.src.w;
|
|
|
|
float3 _2_sda = _in.src.xyz * _in.dst.w;
|
|
|
|
float3 _3_dsa = _in.dst.xyz * _in.src.w;
|
2020-11-18 20:38:39 +00:00
|
|
|
float3 _4_blend_set_color_saturation;
|
2020-11-23 15:55:00 +00:00
|
|
|
float3 _5_hueLumColor = _2_sda;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
float _6_17_blend_color_saturation;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_6_17_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);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
float _7_sat = _6_17_blend_color_saturation;
|
2020-09-25 17:35:58 +00:00
|
|
|
|
2020-11-23 15:55:00 +00:00
|
|
|
if (_5_hueLumColor.x <= _5_hueLumColor.y) {
|
|
|
|
if (_5_hueLumColor.y <= _5_hueLumColor.z) {
|
|
|
|
float3 _8_18_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_8_18_blend_set_color_saturation_helper = _5_hueLumColor.x < _5_hueLumColor.z ? float3(0.0, (_7_sat * (_5_hueLumColor.y - _5_hueLumColor.x)) / (_5_hueLumColor.z - _5_hueLumColor.x), _7_sat) : float3(0.0);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_5_hueLumColor.xyz = _8_18_blend_set_color_saturation_helper;
|
2020-09-28 17:13:40 +00:00
|
|
|
|
2020-11-23 15:55:00 +00:00
|
|
|
} else if (_5_hueLumColor.x <= _5_hueLumColor.z) {
|
|
|
|
float3 _9_19_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_9_19_blend_set_color_saturation_helper = _5_hueLumColor.x < _5_hueLumColor.y ? float3(0.0, (_7_sat * (_5_hueLumColor.z - _5_hueLumColor.x)) / (_5_hueLumColor.y - _5_hueLumColor.x), _7_sat) : float3(0.0);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_5_hueLumColor.xzy = _9_19_blend_set_color_saturation_helper;
|
2020-09-28 17:13:40 +00:00
|
|
|
|
2020-10-15 14:32:04 +00:00
|
|
|
} else {
|
2020-11-23 15:55:00 +00:00
|
|
|
float3 _10_20_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_10_20_blend_set_color_saturation_helper = _5_hueLumColor.z < _5_hueLumColor.y ? float3(0.0, (_7_sat * (_5_hueLumColor.x - _5_hueLumColor.z)) / (_5_hueLumColor.y - _5_hueLumColor.z), _7_sat) : float3(0.0);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_5_hueLumColor.zxy = _10_20_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
|
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
} else if (_5_hueLumColor.x <= _5_hueLumColor.z) {
|
|
|
|
float3 _11_21_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_11_21_blend_set_color_saturation_helper = _5_hueLumColor.y < _5_hueLumColor.z ? float3(0.0, (_7_sat * (_5_hueLumColor.x - _5_hueLumColor.y)) / (_5_hueLumColor.z - _5_hueLumColor.y), _7_sat) : float3(0.0);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_5_hueLumColor.yxz = _11_21_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
|
2020-11-23 15:55:00 +00:00
|
|
|
} else if (_5_hueLumColor.y <= _5_hueLumColor.z) {
|
|
|
|
float3 _12_22_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_12_22_blend_set_color_saturation_helper = _5_hueLumColor.y < _5_hueLumColor.x ? float3(0.0, (_7_sat * (_5_hueLumColor.z - _5_hueLumColor.y)) / (_5_hueLumColor.x - _5_hueLumColor.y), _7_sat) : float3(0.0);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_5_hueLumColor.yzx = _12_22_blend_set_color_saturation_helper;
|
2020-09-25 17:35:58 +00:00
|
|
|
|
2020-10-15 14:32:04 +00:00
|
|
|
} else {
|
2020-11-23 15:55:00 +00:00
|
|
|
float3 _13_23_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_13_23_blend_set_color_saturation_helper = _5_hueLumColor.z < _5_hueLumColor.x ? float3(0.0, (_7_sat * (_5_hueLumColor.y - _5_hueLumColor.z)) / (_5_hueLumColor.x - _5_hueLumColor.z), _7_sat) : float3(0.0);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_5_hueLumColor.zyx = _13_23_blend_set_color_saturation_helper;
|
2020-10-15 14:32:04 +00:00
|
|
|
|
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_4_blend_set_color_saturation = _5_hueLumColor;
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
float3 _14_blend_set_color_luminance;
|
2020-10-15 14:32:04 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
float _15_15_blend_color_luminance;
|
2020-09-25 17:35:58 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_15_15_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_dsa);
|
2020-09-25 17:35:58 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
float _16_lum = _15_15_blend_color_luminance;
|
2020-09-25 17:35:58 +00:00
|
|
|
|
2020-11-23 15:55:00 +00:00
|
|
|
float _17_16_blend_color_luminance;
|
2020-10-12 15:21:35 +00:00
|
|
|
{
|
2020-11-23 15:55:00 +00:00
|
|
|
_17_16_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _4_blend_set_color_saturation);
|
2020-09-28 17:13:40 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
float3 _18_result = (_16_lum - _17_16_blend_color_luminance) + _4_blend_set_color_saturation;
|
2020-10-12 15:21:35 +00:00
|
|
|
|
2020-11-23 15:55:00 +00:00
|
|
|
float _19_minComp = min(min(_18_result.x, _18_result.y), _18_result.z);
|
|
|
|
float _20_maxComp = max(max(_18_result.x, _18_result.y), _18_result.z);
|
|
|
|
if (_19_minComp < 0.0 && _16_lum != _19_minComp) {
|
|
|
|
_18_result = _16_lum + ((_18_result - _16_lum) * _16_lum) / (_16_lum - _19_minComp);
|
2020-10-15 14:32:04 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_14_blend_set_color_luminance = _20_maxComp > _1_alpha && _20_maxComp != _16_lum ? _16_lum + ((_18_result - _16_lum) * (_1_alpha - _16_lum)) / (_20_maxComp - _16_lum) : _18_result;
|
2020-09-25 17:35:58 +00:00
|
|
|
}
|
2020-11-23 15:55:00 +00:00
|
|
|
_0_blend_hue = float4((((_14_blend_set_color_luminance + _in.dst.xyz) - _3_dsa) + _in.src.xyz) - _2_sda, (_in.src.w + _in.dst.w) - _1_alpha);
|
2020-09-25 17:35:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
2020-10-13 15:19:41 +00:00
|
|
|
_out->sk_FragColor = _0_blend_hue;
|
2020-09-28 17:13:40 +00:00
|
|
|
|
2020-09-25 17:35:58 +00:00
|
|
|
return *_out;
|
|
|
|
}
|