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-09-25 17:35:58 +00:00
|
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
|
|
|
Outputs _outputStruct;
|
|
|
|
thread Outputs* _out = &_outputStruct;
|
2020-12-15 22:50:21 +00:00
|
|
|
float _1_alpha;
|
|
|
|
float3 _2_sda;
|
|
|
|
float3 _3_dsa;
|
|
|
|
_1_alpha = _in.dst.w * _in.src.w;
|
|
|
|
_2_sda = _in.src.xyz * _in.dst.w;
|
|
|
|
_3_dsa = _in.dst.xyz * _in.src.w;
|
2020-10-15 14:32:04 +00:00
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
float _5_lum;
|
|
|
|
float3 _6_result;
|
|
|
|
float _7_minComp;
|
|
|
|
float _8_maxComp;
|
|
|
|
_5_lum = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _2_sda);
|
2020-12-15 20:21:03 +00:00
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
_6_result = (_5_lum - dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_dsa)) + _3_dsa;
|
2020-12-15 20:21:03 +00:00
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
_7_minComp = min(min(_6_result.x, _6_result.y), _6_result.z);
|
|
|
|
_8_maxComp = max(max(_6_result.x, _6_result.y), _6_result.z);
|
|
|
|
if (_7_minComp < 0.0 && _5_lum != _7_minComp) {
|
|
|
|
_6_result = _5_lum + ((_6_result - _5_lum) * _5_lum) / (_5_lum - _7_minComp);
|
2020-09-25 17:35:58 +00:00
|
|
|
}
|
2020-12-15 20:21:03 +00:00
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
_out->sk_FragColor = float4(((((_8_maxComp > _1_alpha && _8_maxComp != _5_lum ? _5_lum + ((_6_result - _5_lum) * (_1_alpha - _5_lum)) / (_8_maxComp - _5_lum) : _6_result) + _in.dst.xyz) - _3_dsa) + _in.src.xyz) - _2_sda, (_in.src.w + _in.dst.w) - _1_alpha);
|
2020-12-15 20:21:03 +00:00
|
|
|
|
2020-09-25 17:35:58 +00:00
|
|
|
|
|
|
|
return *_out;
|
|
|
|
}
|