#include #include constexpr constant float c_scale = 1.2; struct VertexOutput { metal::float2 uv; metal::float4 position; }; struct main1Input { metal::float2 pos [[attribute(0)]]; metal::float2 uv [[attribute(1)]]; }; struct main1Output { metal::float2 uv [[user(loc0), center_perspective]]; metal::float4 position [[position]]; }; vertex main1Output main1( main1Input varyings [[stage_in]] ) { const auto pos = varyings.pos; const auto uv = varyings.uv; const auto _tmp = VertexOutput {uv, metal::float4(c_scale * pos, 0.0, 1.0)}; return main1Output { _tmp.uv, _tmp.position }; } struct main2Input { metal::float2 uv1 [[user(loc0), center_perspective]]; }; struct main2Output { metal::float4 member1 [[color(0)]]; }; fragment main2Output main2( main2Input varyings1 [[stage_in]] , metal::texture2d u_texture [[user(fake0)]] , metal::sampler u_sampler [[user(fake0)]] ) { const auto uv1 = varyings1.uv1; metal::float4 color = u_texture.sample(u_sampler, uv1); if (color.w == 0.0) { metal::discard_fragment(); } metal::float4 premultiplied = color.w * color; return main2Output { premultiplied }; } struct fs_extraOutput { metal::float4 member2 [[color(0)]]; }; fragment fs_extraOutput fs_extra( ) { return fs_extraOutput { metal::float4(0.0, 0.5, 0.0, 0.5) }; }