2021-03-15 18:58:57 +00:00
|
|
|
struct Uniforms {
|
2020-10-06 18:43:32 +00:00
|
|
|
float4 src;
|
|
|
|
float4 dst;
|
2020-09-25 17:35:58 +00:00
|
|
|
};
|
2021-03-15 18:58:57 +00:00
|
|
|
struct Inputs {
|
|
|
|
};
|
2020-09-25 17:35:58 +00:00
|
|
|
struct Outputs {
|
|
|
|
float4 sk_FragColor [[color(0)]];
|
|
|
|
};
|
2020-11-23 19:48:06 +00:00
|
|
|
float3 _blend_set_color_saturation_helper(float3 minMidMax, float sat) {
|
2021-02-10 17:03:42 +00:00
|
|
|
if (minMidMax.x < minMidMax.z) {
|
2021-02-25 16:17:02 +00:00
|
|
|
float _7_n = sat * (minMidMax.y - minMidMax.x);
|
|
|
|
float _8_d = minMidMax.z - minMidMax.x;
|
|
|
|
return float3(0.0, _7_n / _8_d, sat);
|
2021-02-10 17:03:42 +00:00
|
|
|
} else {
|
|
|
|
return float3(0.0);
|
|
|
|
}
|
2020-11-23 19:48:06 +00:00
|
|
|
}
|
2021-03-15 18:30:06 +00:00
|
|
|
|
2021-03-15 18:58:57 +00:00
|
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
2021-03-15 18:30:06 +00:00
|
|
|
Outputs _out;
|
|
|
|
(void)_out;
|
2021-03-15 18:58:57 +00:00
|
|
|
float _0_alpha = _uniforms.dst.w * _uniforms.src.w;
|
|
|
|
float3 _1_sda = _uniforms.src.xyz * _uniforms.dst.w;
|
|
|
|
float3 _2_dsa = _uniforms.dst.xyz * _uniforms.src.w;
|
2021-03-15 22:08:38 +00:00
|
|
|
float3 _3_blend_set_color_saturation;
|
|
|
|
float _4_sat = max(max(_2_dsa.x, _2_dsa.y), _2_dsa.z) - min(min(_2_dsa.x, _2_dsa.y), _2_dsa.z);
|
|
|
|
if (_1_sda.x <= _1_sda.y) {
|
|
|
|
if (_1_sda.y <= _1_sda.z) {
|
|
|
|
_3_blend_set_color_saturation = _blend_set_color_saturation_helper(_1_sda, _4_sat);
|
|
|
|
} else if (_1_sda.x <= _1_sda.z) {
|
|
|
|
_3_blend_set_color_saturation = _blend_set_color_saturation_helper(_1_sda.xzy, _4_sat).xzy;
|
|
|
|
} else {
|
|
|
|
_3_blend_set_color_saturation = _blend_set_color_saturation_helper(_1_sda.zxy, _4_sat).yzx;
|
|
|
|
}
|
|
|
|
} else if (_1_sda.x <= _1_sda.z) {
|
|
|
|
_3_blend_set_color_saturation = _blend_set_color_saturation_helper(_1_sda.yxz, _4_sat).yxz;
|
|
|
|
} else if (_1_sda.y <= _1_sda.z) {
|
|
|
|
_3_blend_set_color_saturation = _blend_set_color_saturation_helper(_1_sda.yzx, _4_sat).zxy;
|
|
|
|
} else {
|
|
|
|
_3_blend_set_color_saturation = _blend_set_color_saturation_helper(_1_sda.zyx, _4_sat).zyx;
|
|
|
|
}
|
|
|
|
float3 _5_blend_set_color_luminance;
|
|
|
|
float _6_lum = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _2_dsa);
|
|
|
|
float3 _7_result = (_6_lum - dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_blend_set_color_saturation)) + _3_blend_set_color_saturation;
|
|
|
|
float _8_minComp = min(min(_7_result.x, _7_result.y), _7_result.z);
|
|
|
|
float _9_maxComp = max(max(_7_result.x, _7_result.y), _7_result.z);
|
|
|
|
if (_8_minComp < 0.0 && _6_lum != _8_minComp) {
|
|
|
|
float _10_d = _6_lum - _8_minComp;
|
|
|
|
_7_result = _6_lum + (_7_result - _6_lum) * (_6_lum / _10_d);
|
|
|
|
}
|
|
|
|
if (_9_maxComp > _0_alpha && _9_maxComp != _6_lum) {
|
|
|
|
float3 _11_n = (_7_result - _6_lum) * (_0_alpha - _6_lum);
|
|
|
|
float _12_d = _9_maxComp - _6_lum;
|
|
|
|
_5_blend_set_color_luminance = _6_lum + _11_n / _12_d;
|
|
|
|
} else {
|
|
|
|
_5_blend_set_color_luminance = _7_result;
|
|
|
|
}
|
2021-03-15 18:58:57 +00:00
|
|
|
_out.sk_FragColor = float4((((_5_blend_set_color_luminance + _uniforms.dst.xyz) - _2_dsa) + _uniforms.src.xyz) - _1_sda, (_uniforms.src.w + _uniforms.dst.w) - _0_alpha);
|
2021-01-19 18:07:55 +00:00
|
|
|
return _out;
|
2020-09-25 17:35:58 +00:00
|
|
|
}
|