2021-03-16 14:40:11 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
2021-03-15 18:58:57 +00:00
|
|
|
struct Uniforms {
|
2021-10-30 02:34:51 +00:00
|
|
|
half4 src;
|
|
|
|
half4 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 {
|
2021-10-30 02:34:51 +00:00
|
|
|
half4 sk_FragColor [[color(0)]];
|
2020-09-25 17:35:58 +00:00
|
|
|
};
|
2022-01-25 14:42:12 +00:00
|
|
|
half blend_overlay_component_Qhh2h2(half2 s, half2 d) {
|
2021-10-30 02:34:51 +00:00
|
|
|
return 2.0h * d.x <= d.y ? (2.0h * s.x) * d.x : s.y * d.y - (2.0h * (d.y - d.x)) * (s.y - s.x);
|
2020-11-23 19:48: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-01-19 18:07:55 +00:00
|
|
|
Outputs _out;
|
2021-01-22 03:24:28 +00:00
|
|
|
(void)_out;
|
2022-01-25 14:42:12 +00:00
|
|
|
half4 _0_result = half4(blend_overlay_component_Qhh2h2(_uniforms.src.xw, _uniforms.dst.xw), blend_overlay_component_Qhh2h2(_uniforms.src.yw, _uniforms.dst.yw), blend_overlay_component_Qhh2h2(_uniforms.src.zw, _uniforms.dst.zw), _uniforms.src.w + (1.0h - _uniforms.src.w) * _uniforms.dst.w);
|
2021-10-30 02:34:51 +00:00
|
|
|
_0_result.xyz = _0_result.xyz + _uniforms.dst.xyz * (1.0h - _uniforms.src.w) + _uniforms.src.xyz * (1.0h - _uniforms.dst.w);
|
2021-03-15 22:08:38 +00:00
|
|
|
_out.sk_FragColor = _0_result;
|
2021-01-19 18:07:55 +00:00
|
|
|
return _out;
|
2020-09-25 17:35:58 +00:00
|
|
|
}
|