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-11-23 19:48:06 +00:00
|
|
|
float _blend_overlay_component(float2 s, float2 d) {
|
|
|
|
return 2.0 * d.x <= d.y ? (2.0 * s.x) * d.x : s.y * d.y - (2.0 * (d.y - d.x)) * (s.y - s.x);
|
|
|
|
}
|
2020-09-25 17:35:58 +00:00
|
|
|
|
2020-09-28 17:13:40 +00:00
|
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], 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;
|
2021-02-25 16:17:02 +00:00
|
|
|
float4 _0_result = float4(_blend_overlay_component(_in.src.xw, _in.dst.xw), _blend_overlay_component(_in.src.yw, _in.dst.yw), _blend_overlay_component(_in.src.zw, _in.dst.zw), _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
|
|
|
_0_result.xyz = _0_result.xyz + _in.dst.xyz * (1.0 - _in.src.w) + _in.src.xyz * (1.0 - _in.dst.w);
|
|
|
|
_out.sk_FragColor = _0_result;
|
2021-01-19 18:07:55 +00:00
|
|
|
return _out;
|
2020-09-25 17:35:58 +00:00
|
|
|
}
|